Merge pull request #38400 from frappe/mergify/bp/version-15-hotfix/pr-38398

fix(CRM): create contact if existing customer doesn't have contact (backport #38398)
This commit is contained in:
Shariq Ansari 2023-11-28 20:45:34 +05:30 committed by GitHub
commit 9f873749e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -34,6 +34,15 @@ class Lead(SellingController, CRMNote):
def before_insert(self):
self.contact_doc = None
if frappe.db.get_single_value("CRM Settings", "auto_creation_of_contact"):
if self.source == "Existing Customer" and self.customer:
contact = frappe.db.get_value(
"Dynamic Link",
{"link_doctype": "Customer", "link_name": self.customer},
"parent",
)
if contact:
self.contact_doc = frappe.get_doc("Contact", contact)
return
self.contact_doc = self.create_contact()
def after_insert(self):