diff --git a/buying/doctype/purchase_common/purchase_common.js b/buying/doctype/purchase_common/purchase_common.js index e15e0764122..04263c3a5ec 100644 --- a/buying/doctype/purchase_common/purchase_common.js +++ b/buying/doctype/purchase_common/purchase_common.js @@ -111,11 +111,6 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({ address: this.frm.doc.supplier_address, contact: this.frm.doc.contact_person }, - callback: function(r) { - if(!r.exc) { - me.frm.refresh_fields(); - } - } }); } }, diff --git a/selling/doctype/sales_common/sales_common.js b/selling/doctype/sales_common/sales_common.js index e9f185b5db5..9a13c4f98ce 100644 --- a/selling/doctype/sales_common/sales_common.js +++ b/selling/doctype/sales_common/sales_common.js @@ -165,9 +165,6 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ }, method: "set_customer_address", freeze: true, - callback: function(r) { - me.frm.refresh_fields(); - } }); } }, diff --git a/utilities/transaction_base.py b/utilities/transaction_base.py index de229b9162c..8894cb4b22a 100644 --- a/utilities/transaction_base.py +++ b/utilities/transaction_base.py @@ -135,10 +135,7 @@ class TransactionBase(StatusUpdater): def set_lead_defaults(self): self.doc.fields.update(self.get_lead_defaults()) - - # Get Customer Address - # ----------------------- def get_customer_address(self, args): args = load_json(args) ret = { @@ -396,14 +393,10 @@ def map_party_contact_details(contact_name=None, party_field=None, party_name=No "contact_mobile", "contact_phone", "contact_designation", "contact_department"]: out[fieldname] = None - condition = "" - if contact_name: - condition = " name = '%s'" % contact_name - elif party_field and party_name: - condition = " `%s`='%s'" % (party_field, party_name) - - contact = webnotes.conn.sql("""select * from `tabContact` where %s - order by is_primary_contact desc, name asc limit 1""" % condition, as_dict=True) + if not contact_name and party_field: + contact_name = get_default_contact(party_field, party_name) + + contact = webnotes.conn.sql("""select * from `tabContact` where name=%s""", contact_name, as_dict=True) if contact: contact = contact[0] @@ -417,7 +410,7 @@ def map_party_contact_details(contact_name=None, party_field=None, party_name=No "contact_designation": contact.get("designation"), "contact_department": contact.get("department") }) - + return out def get_address_territory(address_doc):