Skip to content

Commit

Permalink
fix: create contact if existing customer doesn't have contact
Browse files Browse the repository at this point in the history
(cherry picked from commit 23b0b8b)
  • Loading branch information
shariquerik authored and mergify[bot] committed Nov 28, 2023
1 parent 33b3355 commit b1b065d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions erpnext/crm/doctype/lead/lead.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit b1b065d

Please sign in to comment.