From 84d73103f8c0351aeac5664c9a49c473cea51a86 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 14 Feb 2012 15:13:21 +0530 Subject: [PATCH] sales team mapping issue in SO-DN and SO-RV --- .../doctype/receivable_voucher/receivable_voucher.js | 9 ++++++--- erpnext/stock/doctype/delivery_note/delivery_note.js | 7 ++++--- erpnext/utilities/transaction_base.py | 7 ++++--- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.js b/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.js index aa12ab88a4..386f4620d0 100644 --- a/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.js +++ b/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.js @@ -38,7 +38,7 @@ cur_frm.cscript.onload_post_render = function(doc, dt, dn) { 'load_default_accounts','', function(r,rt) { refresh_field('entries'); - cur_frm.cscript.customer(doc,dt,dn); + cur_frm.cscript.customer(doc,dt,dn,onload=true); } ); } @@ -137,18 +137,21 @@ cur_frm.cscript.warehouse = function(doc, cdt , cdn) { //Customer -cur_frm.cscript.customer = function(doc,dt,dn) { +cur_frm.cscript.customer = function(doc,dt,dn,onload) { var callback = function(r,rt) { var doc = locals[cur_frm.doctype][cur_frm.docname]; get_server_fields('get_debit_to','','',doc, dt, dn, 0); cur_frm.refresh(); } + var args = onload ? 'onload':'' + if(doc.customer) $c_obj(make_doclist(doc.doctype, doc.name), 'get_default_customer_address', args, callback); - if(doc.customer) $c_obj(make_doclist(doc.doctype, doc.name), 'get_default_customer_address', '', callback); if(doc.customer) unhide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']); } + + cur_frm.cscript.customer_address = cur_frm.cscript.contact_person = function(doc,dt,dn) { if(doc.customer) get_server_fields('get_customer_address', JSON.stringify({customer: doc.customer, address: doc.customer_address, contact: doc.contact_person}),'', doc, dt, dn, 1); } diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.js b/erpnext/stock/doctype/delivery_note/delivery_note.js index b6329c50d3..d9f479504a 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.js +++ b/erpnext/stock/doctype/delivery_note/delivery_note.js @@ -61,12 +61,13 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) { //customer -cur_frm.cscript.customer = function(doc,dt,dn) { +cur_frm.cscript.customer = function(doc,dt,dn,onload) { var callback = function(r,rt) { var doc = locals[cur_frm.doctype][cur_frm.docname]; cur_frm.refresh(); } - if(doc.customer) $c_obj(make_doclist(doc.doctype, doc.name), 'get_default_customer_shipping_address', '', callback); + var args = onload ? 'onload':'' + if(doc.customer) $c_obj(make_doclist(doc.doctype, doc.name), 'get_default_customer_shipping_address', args, callback); if(doc.customer) unhide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group','shipping_address']); } @@ -112,7 +113,7 @@ cur_frm.cscript['Get Items'] = function(doc,dt,dn) { cur_frm.cscript.pull_item_details_onload = function(doc,dt,dn){ var callback = function(r,rt){ refresh_field('delivery_note_details'); - cur_frm.cscript.customer(doc,dt,dn); + cur_frm.cscript.customer(doc,dt,dn,onload=true); } $c_obj(make_doclist(dt,dn),'set_item_details','',callback); } diff --git a/erpnext/utilities/transaction_base.py b/erpnext/utilities/transaction_base.py index 7979036171..7cb7479cec 100644 --- a/erpnext/utilities/transaction_base.py +++ b/erpnext/utilities/transaction_base.py @@ -19,7 +19,8 @@ class TransactionBase: self.doc.contact_mobile = contact_mobile or '' self.get_customer_details(self.doc.customer) - self.get_sales_person(self.doc.customer) + if args != 'onload': + self.get_sales_person(self.doc.customer) # Get Customer Default Shipping Address - first load # ----------------------- @@ -34,8 +35,8 @@ class TransactionBase: self.doc.contact_mobile = contact_mobile or '' self.get_customer_details(self.doc.customer) - if self.doc.doctype != 'Quotation': - self.get_sales_person(self.doc.customer) + if self.doc.doctype != 'Quotation' and args != 'onload': + self.get_sales_person(self.doc.customer) # Get Customer Address # -----------------------