From 7490242f8c4aaac42c0a9d12b11dcf002763858a Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 28 Feb 2013 17:15:28 +0530 Subject: [PATCH 1/8] fixed flt for group separator '.' --- public/js/legacy/utils/datatype.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/js/legacy/utils/datatype.js b/public/js/legacy/utils/datatype.js index db86bd5bd9..718f79efa6 100644 --- a/public/js/legacy/utils/datatype.js +++ b/public/js/legacy/utils/datatype.js @@ -107,7 +107,7 @@ function flt(v, decimals) { } // strip groups (,) - if(wn.number_format_info.group_sep==".") { + if(wn.number_format_info[get_number_format()].group_sep==".") { v = v.replace(/\./g,''); // sanitize decimal separator to . From cc0ed5c732b87af66d335afeb8453b5d8df5304d Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 28 Feb 2013 18:49:39 +0530 Subject: [PATCH 2/8] show a well formatted error message when error in client script --- public/js/legacy/widgets/form/form.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/public/js/legacy/widgets/form/form.js b/public/js/legacy/widgets/form/form.js index 6a2c263bee..3c99fa3994 100644 --- a/public/js/legacy/widgets/form/form.js +++ b/public/js/legacy/widgets/form/form.js @@ -789,7 +789,16 @@ _f.Frm.prototype.runclientscript = function(caller, cdt, cdn) { } catch(e) { validated = false; + + // show error message + console.group && console.group(); + console.log("----- error in client script -----"); + console.log("method: " + caller); console.log(e); + console.log("error message: " + e.message); + console.trace && console.trace(); + console.log("----- end of error message -----"); + console.group && console.groupEnd(); } if(caller && caller.toLowerCase()=='setup') { this.setup_client_js(); From 2ea57f135ef0855316feea926aee87ee1c8c249a Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 1 Mar 2013 11:39:37 +0530 Subject: [PATCH 3/8] show better error message for client script errors --- public/js/legacy/widgets/form/form.js | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/public/js/legacy/widgets/form/form.js b/public/js/legacy/widgets/form/form.js index 3c99fa3994..e5aa7e33d8 100644 --- a/public/js/legacy/widgets/form/form.js +++ b/public/js/legacy/widgets/form/form.js @@ -791,14 +791,7 @@ _f.Frm.prototype.runclientscript = function(caller, cdt, cdn) { validated = false; // show error message - console.group && console.group(); - console.log("----- error in client script -----"); - console.log("method: " + caller); - console.log(e); - console.log("error message: " + e.message); - console.trace && console.trace(); - console.log("----- end of error message -----"); - console.group && console.groupEnd(); + this.log_error(caller, e); } if(caller && caller.toLowerCase()=='setup') { this.setup_client_js(); @@ -815,8 +808,8 @@ _f.Frm.prototype.setup_client_js = function(caller, cdt, cdn) { try { var tmp = eval(cs); } catch(e) { - show_alert("Error in Client Script.") - console.log(e); + show_alert("Error in Client Script."); + this.log_error(caller || "setup_client_js", e); } } @@ -833,6 +826,17 @@ _f.Frm.prototype.setup_client_js = function(caller, cdt, cdn) { } } +_f.Frm.prototype.log_error = function(caller, e) { + console.group && console.group(); + console.log("----- error in client script -----"); + console.log("method: " + caller); + console.log(e); + console.log("error message: " + e.message); + console.trace && console.trace(); + console.log("----- end of error message -----"); + console.group && console.groupEnd(); +} + _f.Frm.prototype.copy_doc = function(onload, from_amend) { if(!this.perm[0][CREATE]) { msgprint('You are not allowed to create '+this.meta.name); From 28267da3e90f70562a3ba857163bc411c040bb80 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 1 Mar 2013 12:57:02 +0530 Subject: [PATCH 4/8] allow attach for batch --- core/doctype/customize_form/customize_form.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/doctype/customize_form/customize_form.js b/core/doctype/customize_form/customize_form.js index 0b011d12d8..fde24deedd 100644 --- a/core/doctype/customize_form/customize_form.js +++ b/core/doctype/customize_form/customize_form.js @@ -94,7 +94,7 @@ cur_frm.cscript.hide_allow_attach = function(doc, dt, dn) { 'Leave Application', 'Lead', 'Journal Voucher', 'Item', 'Material Request', 'Expense Claim', 'Opportunity', 'Employee', 'Delivery Note', 'Customer Issue', 'Customer', 'Contact Us Settings', 'Company', - 'Blog', 'BOM', 'About Us Settings']; + 'Blog', 'BOM', 'About Us Settings', 'Batch']; if(inList(allow_attach_list, doc.doc_type)) { unhide_field('allow_attach'); From 479ac0273f6c1734f3efd5176dc73f91ff0096ac Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 1 Mar 2013 13:21:29 +0530 Subject: [PATCH 5/8] datatype validation in voucher import tool --- core/page/data_import_tool/data_import_tool.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/page/data_import_tool/data_import_tool.py b/core/page/data_import_tool/data_import_tool.py index ee5493b4db..879f4b40c0 100644 --- a/core/page/data_import_tool/data_import_tool.py +++ b/core/page/data_import_tool/data_import_tool.py @@ -129,7 +129,7 @@ def get_template(): webnotes.response['doctype'] = doctype def getdocfield(fieldname): - """get docfield from doclist of doctype""" + """get docfield from doclist of doctype""" l = [d for d in doctype_dl if d.doctype=='DocField' and d.fieldname==fieldname] return l and l[0] or None @@ -256,6 +256,10 @@ def check_record(d, parenttype): if parenttype and not d.get('parent'): raise Exception, "parent is required." + global doctype_dl + if not doctype_dl: + doctype_dl = webnotes.model.doctype.get(d.doctype) + for key in d: docfield = getdocfield(key) val = d[key] From 0e138090d814fa4959c73e192a7e6b561ff3455d Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 1 Mar 2013 13:42:56 +0530 Subject: [PATCH 6/8] fix in flt and number format when number format is not one of the predefined ones --- public/js/legacy/utils/datatype.js | 2 +- public/js/wn/misc/number_format.js | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/public/js/legacy/utils/datatype.js b/public/js/legacy/utils/datatype.js index 718f79efa6..7f62f59495 100644 --- a/public/js/legacy/utils/datatype.js +++ b/public/js/legacy/utils/datatype.js @@ -107,7 +107,7 @@ function flt(v, decimals) { } // strip groups (,) - if(wn.number_format_info[get_number_format()].group_sep==".") { + if(get_number_format_info(get_number_format()).group_sep==".") { v = v.replace(/\./g,''); // sanitize decimal separator to . diff --git a/public/js/wn/misc/number_format.js b/public/js/wn/misc/number_format.js index 4d9e408659..d8fa2ce7b6 100644 --- a/public/js/wn/misc/number_format.js +++ b/public/js/wn/misc/number_format.js @@ -12,14 +12,10 @@ wn.number_format_info = { } window.format_number = function(v, format, decimals){ - if (!format) { format = get_number_format(); } - var info = wn.number_format_info[format]; - if(!info) { - info = {decimal_str:".", group_sep:",", precision:2}; - } + info = get_number_format_info(format); if(isNaN(+v) || v==null) { v=0; @@ -105,4 +101,12 @@ function get_number_format() { || "#,###.##"; } return global_number_format; +} + +function get_number_format_info(format) { + var info = wn.number_format_info[format]; + if(!info) { + info = {decimal_str:".", group_sep:",", precision:2}; + } + return info; } \ No newline at end of file From 08bead41041c47f30580a4b1516ec00df77febcc Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 1 Mar 2013 15:31:23 +0530 Subject: [PATCH 7/8] changed temp container id to temp-container from #temp-container --- public/js/wn/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/js/wn/app.js b/public/js/wn/app.js index ce3bcecf00..a0213d29c2 100644 --- a/public/js/wn/app.js +++ b/public/js/wn/app.js @@ -104,7 +104,7 @@ wn.Application = Class.extend({ }, make_page_container: function() { if($("#body_div").length) { - wn.temp_container = $("