[Mod] Code refactored to remove dependency on 'complete_address' field

This commit is contained in:
Saurabh 2018-02-09 10:49:30 +05:30
parent 0de0861bb4
commit b4ab89e1da
3 changed files with 19 additions and 3 deletions

View File

@ -43,6 +43,18 @@ frappe.ui.form.on("Customer", {
}) })
}, },
customer_primary_address: function(frm){ 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){ if(!frm.doc.customer_primary_address){
frm.set_value("primary_address", ""); frm.set_value("primary_address", "");
} }
@ -92,4 +104,4 @@ frappe.ui.form.on("Customer", {
validate: function(frm) { validate: function(frm) {
if(frm.doc.lead_name) frappe.model.clear_doc("Lead", frm.doc.lead_name); if(frm.doc.lead_name) frappe.model.clear_doc("Lead", frm.doc.lead_name);
}, },
}); });

View File

@ -924,7 +924,7 @@
"label": "Primary Address", "label": "Primary Address",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
"options": "customer_primary_address.complete_address", "options": "",
"permlevel": 0, "permlevel": 0,
"precision": "", "precision": "",
"print_hide": 0, "print_hide": 0,
@ -1449,7 +1449,7 @@
"issingle": 0, "issingle": 0,
"istable": 0, "istable": 0,
"max_attachments": 0, "max_attachments": 0,
"modified": "2018-02-02 16:07:11.052268", "modified": "2018-02-09 10:44:35.801716",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Selling", "module": "Selling",
"name": "Customer", "name": "Customer",

View File

@ -77,6 +77,10 @@ class Customer(TransactionBase):
if self.flags.is_new_doc and self.get('address_line1'): if self.flags.is_new_doc and self.get('address_line1'):
make_address(self) 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): def update_lead_status(self):
'''If Customer created from Lead, update lead status to "Converted" '''If Customer created from Lead, update lead status to "Converted"
update Customer link in Quotation, Opportunity''' update Customer link in Quotation, Opportunity'''