Merge pull request #23212 from marination/customer-from-quotation

fix: Better error feedback on creating SO from Quotation
This commit is contained in:
Deepesh Garg 2020-08-30 23:24:02 +05:30 committed by GitHub
commit a03ebf007c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -285,9 +285,17 @@ def _make_customer(source_name, ignore_permissions=False):
return customer
else:
raise
except frappe.MandatoryError:
except frappe.MandatoryError as e:
mandatory_fields = e.args[0].split(':')[1].split(',')
mandatory_fields = [customer.meta.get_label(field.strip()) for field in mandatory_fields]
frappe.local.message_log = []
frappe.throw(_("Please create Customer from Lead {0}").format(lead_name))
lead_link = frappe.utils.get_link_to_form("Lead", lead_name)
message = _("Could not auto create Customer due to the following missing mandatory field(s):") + "<br>"
message += "<br><ul><li>" + "</li><li>".join(mandatory_fields) + "</li></ul>"
message += _("Please create Customer from Lead {0}.").format(lead_link)
frappe.throw(message, title=_("Mandatory Missing"))
else:
return customer_name
else: