From 461b417871bd48b567a4086bb61761fcbe40d9de Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Sat, 20 Jul 2013 18:29:45 +0530 Subject: [PATCH] [minor] [fix] trigger in supplier address and contact person field --- .../purchase_invoice/purchase_invoice.js | 5 ---- .../purchase_common/purchase_common.js | 25 +++++++++++++++++++ .../doctype/purchase_order/purchase_order.js | 4 --- .../supplier_quotation/supplier_quotation.js | 8 ------ .../purchase_receipt/purchase_receipt.js | 4 --- 5 files changed, 25 insertions(+), 21 deletions(-) diff --git a/accounts/doctype/purchase_invoice/purchase_invoice.js b/accounts/doctype/purchase_invoice/purchase_invoice.js index 4afb838f68..2bdab8ac0b 100644 --- a/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -109,11 +109,6 @@ erpnext.accounts.PurchaseInvoiceController = erpnext.buying.BuyingController.ext // for backward compatibility: combine new and previous states $.extend(cur_frm.cscript, new erpnext.accounts.PurchaseInvoiceController({frm: cur_frm})); - -cur_frm.cscript.supplier_address = cur_frm.cscript.contact_person = function(doc,dt,dn) { - if(doc.supplier) get_server_fields('get_supplier_address', JSON.stringify({supplier: doc.supplier, address: doc.supplier_address, contact: doc.contact_person}),'', doc, dt, dn, 1); -} - cur_frm.fields_dict['entries'].grid.onrowadd = function(doc, cdt, cdn){ cl = getchildren('Purchase Invoice Item', doc.name, cur_frm.cscript.fname, doc.doctype); diff --git a/buying/doctype/purchase_common/purchase_common.js b/buying/doctype/purchase_common/purchase_common.js index e54319dd05..c05eba8aa3 100644 --- a/buying/doctype/purchase_common/purchase_common.js +++ b/buying/doctype/purchase_common/purchase_common.js @@ -99,6 +99,31 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({ } }, + supplier_address: function() { + var me = this; + if (this.frm.doc.supplier) { + wn.call({ + doc: this.frm.doc, + method: "get_supplier_address", + freeze: true, + args: { + supplier: this.frm.doc.supplier, + address: this.frm.doc.supplier_address, + contact: this.frm.doc.contact_person + }, + callback: function(r) { + if(!r.exc) { + me.frm.refresh_fields(); + } + } + }); + } + }, + + contact_person: function() { + this.supplier_address(); + }, + item_code: function(doc, cdt, cdn) { var me = this; var item = wn.model.get_doc(cdt, cdn); diff --git a/buying/doctype/purchase_order/purchase_order.js b/buying/doctype/purchase_order/purchase_order.js index bccd4a9559..0d3d0ee934 100644 --- a/buying/doctype/purchase_order/purchase_order.js +++ b/buying/doctype/purchase_order/purchase_order.js @@ -105,10 +105,6 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend( // for backward compatibility: combine new and previous states $.extend(cur_frm.cscript, new erpnext.buying.PurchaseOrderController({frm: cur_frm})); -cur_frm.cscript.supplier_address = cur_frm.cscript.contact_person = function(doc,dt,dn) { - if(doc.supplier) get_server_fields('get_supplier_address', JSON.stringify({supplier: doc.supplier, address: doc.supplier_address, contact: doc.contact_person}),'', doc, dt, dn, 1); -} - cur_frm.fields_dict['supplier_address'].get_query = function(doc, cdt, cdn) { return { filters: {'supplier': doc.supplier} diff --git a/buying/doctype/supplier_quotation/supplier_quotation.js b/buying/doctype/supplier_quotation/supplier_quotation.js index 722ac002a0..96d8ec11ba 100644 --- a/buying/doctype/supplier_quotation/supplier_quotation.js +++ b/buying/doctype/supplier_quotation/supplier_quotation.js @@ -72,14 +72,6 @@ cur_frm.fields_dict['quotation_items'].grid.get_field('project_name').get_query } } -cur_frm.cscript.supplier_address = function(doc, dt, dn) { - if (doc.supplier) { - get_server_fields("get_supplier_address", JSON.stringify({supplier: doc.supplier, - address: doc.supplier_address, contact: doc.contact_person}), '', doc, dt, dn, 1); - } -} -cur_frm.cscript.contact_person = cur_frm.cscript.supplier_address; - cur_frm.fields_dict['supplier_address'].get_query = function(doc, cdt, cdn) { return { filters:{'supplier': doc.supplier} diff --git a/stock/doctype/purchase_receipt/purchase_receipt.js b/stock/doctype/purchase_receipt/purchase_receipt.js index e21d6a3465..a134da14d3 100644 --- a/stock/doctype/purchase_receipt/purchase_receipt.js +++ b/stock/doctype/purchase_receipt/purchase_receipt.js @@ -111,10 +111,6 @@ erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend // for backward compatibility: combine new and previous states $.extend(cur_frm.cscript, new erpnext.stock.PurchaseReceiptController({frm: cur_frm})); -cur_frm.cscript.supplier_address = cur_frm.cscript.contact_person = function(doc,dt,dn) { - if(doc.supplier) get_server_fields('get_supplier_address', JSON.stringify({supplier: doc.supplier, address: doc.supplier_address, contact: doc.contact_person}),'', doc, dt, dn, 1); -} - cur_frm.fields_dict['supplier_address'].get_query = function(doc, cdt, cdn) { return{ filters:{ 'supplier': doc.supplier}