From b4ab89e1dac3760e51634b7f14ca7def736215ee Mon Sep 17 00:00:00 2001 From: Saurabh Date: Fri, 9 Feb 2018 10:49:30 +0530 Subject: [PATCH] [Mod] Code refactored to remove dependency on 'complete_address' field --- erpnext/selling/doctype/customer/customer.js | 14 +++++++++++++- erpnext/selling/doctype/customer/customer.json | 4 ++-- erpnext/selling/doctype/customer/customer.py | 4 ++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/erpnext/selling/doctype/customer/customer.js b/erpnext/selling/doctype/customer/customer.js index 55aaa02428..1994bd31e7 100644 --- a/erpnext/selling/doctype/customer/customer.js +++ b/erpnext/selling/doctype/customer/customer.js @@ -43,6 +43,18 @@ frappe.ui.form.on("Customer", { }) }, customer_primary_address: function(frm){ + if(frm.doc.customer_primary_address){ + frappe.call({ + doc: frm.doc, + args: { + "address_title":frm.doc.customer_primary_address + }, + method: 'get_display', + callback: function(r) { + frm.set_value("primary_address",r.message); + } + }); + } if(!frm.doc.customer_primary_address){ frm.set_value("primary_address", ""); } @@ -92,4 +104,4 @@ frappe.ui.form.on("Customer", { validate: function(frm) { if(frm.doc.lead_name) frappe.model.clear_doc("Lead", frm.doc.lead_name); }, -}); +}); \ No newline at end of file diff --git a/erpnext/selling/doctype/customer/customer.json b/erpnext/selling/doctype/customer/customer.json index 2c846cf0c9..d43de100cf 100644 --- a/erpnext/selling/doctype/customer/customer.json +++ b/erpnext/selling/doctype/customer/customer.json @@ -924,7 +924,7 @@ "label": "Primary Address", "length": 0, "no_copy": 0, - "options": "customer_primary_address.complete_address", + "options": "", "permlevel": 0, "precision": "", "print_hide": 0, @@ -1449,7 +1449,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2018-02-02 16:07:11.052268", + "modified": "2018-02-09 10:44:35.801716", "modified_by": "Administrator", "module": "Selling", "name": "Customer", diff --git a/erpnext/selling/doctype/customer/customer.py b/erpnext/selling/doctype/customer/customer.py index 6f25bf7fd6..94aeed972c 100644 --- a/erpnext/selling/doctype/customer/customer.py +++ b/erpnext/selling/doctype/customer/customer.py @@ -77,6 +77,10 @@ class Customer(TransactionBase): if self.flags.is_new_doc and self.get('address_line1'): make_address(self) + def get_display(self,address_title): + from frappe.contacts.doctype.address.address import get_address_display + return get_address_display(address_title) + def update_lead_status(self): '''If Customer created from Lead, update lead status to "Converted" update Customer link in Quotation, Opportunity'''