Merge pull request #38398 from shariquerik/create-contact-only-if-not-exist
This commit is contained in:
commit
458dd51af7
@ -36,6 +36,15 @@ class Lead(SellingController, CRMNote):
|
|||||||
def before_insert(self):
|
def before_insert(self):
|
||||||
self.contact_doc = None
|
self.contact_doc = None
|
||||||
if frappe.db.get_single_value("CRM Settings", "auto_creation_of_contact"):
|
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()
|
self.contact_doc = self.create_contact()
|
||||||
|
|
||||||
def after_insert(self):
|
def after_insert(self):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user