From 6c8d63f3b92a11a36de2ec1a99e06a8909472baa Mon Sep 17 00:00:00 2001 From: Saurabh Date: Mon, 9 Mar 2020 11:57:47 +0530 Subject: [PATCH] fix: provision to setup new address from lead if address creation break due to mandatory exception --- erpnext/crm/doctype/lead/lead.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/erpnext/crm/doctype/lead/lead.py b/erpnext/crm/doctype/lead/lead.py index cefe32c88b..04f21ffb74 100644 --- a/erpnext/crm/doctype/lead/lead.py +++ b/erpnext/crm/doctype/lead/lead.py @@ -137,10 +137,13 @@ class Lead(SellingController): # skipping country since the system auto-sets it from system defaults address = frappe.new_doc("Address") - mandatory_fields = get_mandatory_fields(address) + mandatory_fields = [ df.fieldname for df in doc.meta.fields if df.reqd ] if not all([self.get(field) for field in mandatory_fields]): - frappe.msgprint(_('Missing mandatory fields in address.'), alert=True, indicator='yellow') + frappe.msgprint(_('Missing mandatory fields in address. \ + {0} to create address' ).format(" Click here "), + alert=True, indicator='yellow') return address.update({addr_field: self.get(addr_field) for addr_field in address_fields}) @@ -374,10 +377,3 @@ def get_lead_with_phone_number(number): lead = leads[0].name if leads else None return lead - -def get_mandatory_fields(doc): - return [ - df.fieldname - for df in doc.meta.fields - if df.reqd - ] \ No newline at end of file