Merge branch 'stable' of github.com:webnotes/erpnext into stable
diff --git a/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.js b/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.js
index b8789b3..c12c2fb 100644
--- a/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.js
+++ b/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.js
@@ -23,9 +23,6 @@
hide_field(['customer_address', 'contact_person', 'customer_name', 'address_display', 'contact_display', 'contact_mobile', 'contact_email', 'territory', 'customer_group']);
- // defined in sales_common.js
- cur_frm.cscript.update_item_details(doc, cdt, cdn);
-
//for previously created sales invoice, set required field related to pos
if(doc.is_pos ==1) cur_frm.cscript.is_pos(doc, dt, dn);
@@ -33,21 +30,22 @@
}
cur_frm.cscript.onload_post_render = function(doc, dt, dn) {
+ var callback = null;
if(doc.customer && doc.__islocal) {
// called from mapper, update the account names for items and customer
- $c_obj(make_doclist(doc.doctype,doc.name),
- 'load_default_accounts','',
- function(r,rt) {
- refresh_field('entries');
- cur_frm.cscript.customer(doc,dt,dn);
- }
- );
+ callback = function(doc, dt, dn) {
+ $c_obj(make_doclist(doc.doctype,doc.name),
+ 'load_default_accounts','',
+ function(r,rt) {
+ refresh_field('entries');
+ cur_frm.cscript.customer(doc,dt,dn);
+ }
+ );
+ }
}
-
- if(!doc.customer && doc.__islocal) {
- // new -- load default taxes
- cur_frm.cscript.load_taxes(doc, cdt, cdn);
- }
+ // defined in sales_common.js
+ cur_frm.cscript.update_item_details(doc, cdt, cdn, callback);
+
}
diff --git a/erpnext/selling/doctype/quotation/quotation.js b/erpnext/selling/doctype/quotation/quotation.js
index 9ba743d..e39b5f0 100644
--- a/erpnext/selling/doctype/quotation/quotation.js
+++ b/erpnext/selling/doctype/quotation/quotation.js
@@ -32,15 +32,11 @@
}
}
- // defined in sales_common.js
- cur_frm.cscript.update_item_details(doc, cdt, cdn);
-
}
cur_frm.cscript.onload_post_render = function(doc, dt, dn) {
- // load default charges
- if(doc.__islocal && !getchildren('RV Tax Detail', doc.name, 'other_charges', doc.doctype).length)
- cur_frm.cscript.load_taxes(doc, cdt, cdn);
+ // defined in sales_common.js
+ cur_frm.cscript.update_item_details(doc, cdt, cdn);
}
// hide - unhide fields based on lead or customer..
diff --git a/erpnext/selling/doctype/sales_common/sales_common.js b/erpnext/selling/doctype/sales_common/sales_common.js
index 57f379c..cdcec5b 100644
--- a/erpnext/selling/doctype/sales_common/sales_common.js
+++ b/erpnext/selling/doctype/sales_common/sales_common.js
@@ -6,18 +6,23 @@
// cur_frm.cscript.sales_team_fname - Sales Team fieldname
// ============== Load Default Taxes ===================
-cur_frm.cscript.load_taxes = function(doc, cdt, cdn) {
+cur_frm.cscript.load_taxes = function(doc, cdt, cdn, callback) {
// run if this is not executed from dt_map...
- if(doc.customer) return;
+ doc = locals[doc.doctype][doc.name];
+ if(doc.customer || getchildren('RV Tax Detail', doc.name, 'other_charges', doc.doctype).length) {
+ if(callback) callback(doc, cdt, cdn);
+ return;
+ }
$c_obj([doc],'load_default_taxes','',function(r,rt){
- refresh_field('other_charges');
+ refresh_field('other_charges');
+ if(callback) callback(doc, cdt, cdn);
});
}
// Gets called after existing item details are update to fill in
// remaining default values
-cur_frm.cscript.load_defaults = function(doc, dt, dn) {
+cur_frm.cscript.load_defaults = function(doc, dt, dn, callback) {
if(!cur_frm.doc.__islocal) { return; }
doc = locals[doc.doctype][doc.name];
@@ -31,11 +36,13 @@
LocalDB.set_default_values(children[i]);
}
refresh_field(cur_frm.cscript.fname);
+ cur_frm.cscript.load_taxes(doc, dt, dn, callback);
}
// Update existing item details
-cur_frm.cscript.update_item_details = function(doc, dt, dn) {
+cur_frm.cscript.update_item_details = function(doc, dt, dn, callback) {
+ doc = locals[doc.doctype][doc.name];
if(!cur_frm.doc.__islocal) return;
var children = getchildren(cur_frm.cscript.tname, doc.name, cur_frm.cscript.fname);
if(children) {
@@ -44,7 +51,7 @@
if(!r.exc) {
refresh_field(cur_frm.cscript.fname);
doc = locals[doc.doctype][doc.name];
- cur_frm.cscript.load_defaults(doc, dt, dn);
+ cur_frm.cscript.load_defaults(doc, dt, dn, callback);
}
});
}
diff --git a/erpnext/selling/doctype/sales_order/sales_order.js b/erpnext/selling/doctype/sales_order/sales_order.js
index 59f8b84..f5f8b58 100644
--- a/erpnext/selling/doctype/sales_order/sales_order.js
+++ b/erpnext/selling/doctype/sales_order/sales_order.js
@@ -23,15 +23,12 @@
hide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group','shipping_address']);
}
- // defined in sales_common.js
- cur_frm.cscript.update_item_details(doc, cdt, cdn);
}
cur_frm.cscript.onload_post_render = function(doc, cdt, cdn) {
if(doc.__islocal) {
- if(doc.quotation) cur_frm.cscript['Pull Quotation Details'](doc,cdt,cdn);
- } else {
- cur_frm.cscript.load_taxes(doc, cdt, cdn);
+ // defined in sales_common.js
+ cur_frm.cscript.update_item_details(doc, cdt, cdn, callback);
}
}
diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.js b/erpnext/stock/doctype/delivery_note/delivery_note.js
index 4099174..b6329c5 100644
--- a/erpnext/stock/doctype/delivery_note/delivery_note.js
+++ b/erpnext/stock/doctype/delivery_note/delivery_note.js
@@ -24,12 +24,13 @@
hide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);
}
- // defined in sales_common.js
- //cur_frm.cscript.update_item_details(doc, cdt, cdn);
}
cur_frm.cscript.onload_post_render = function(doc, dt, dn) {
+ // defined in sales_common.js
+ //cur_frm.cscript.update_item_details(doc, cdt, cdn);
+
// load default charges
if(doc.__islocal && !getchildren('RV Tax Detail', doc.name, 'other_charges', doc.doctype).length)
cur_frm.cscript.load_taxes(doc, cdt, cdn);