diff --git a/erpnext/crm/doctype/lead/lead.py b/erpnext/crm/doctype/lead/lead.py index e897ba41eb04..13dc291cf97d 100644 --- a/erpnext/crm/doctype/lead/lead.py +++ b/erpnext/crm/doctype/lead/lead.py @@ -34,6 +34,15 @@ def validate(self): 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):