|
@ -196,20 +196,19 @@ class Customer(TransactionBase): |
|
|
if not lead.lead_name: |
|
|
if not lead.lead_name: |
|
|
frappe.throw(_("Please mention the Lead Name in Lead {0}").format(self.lead_name)) |
|
|
frappe.throw(_("Please mention the Lead Name in Lead {0}").format(self.lead_name)) |
|
|
|
|
|
|
|
|
if lead.company_name: |
|
|
contact_names = frappe.get_all('Dynamic Link', filters={ |
|
|
contact_names = frappe.get_all('Dynamic Link', filters={ |
|
|
"parenttype":"Contact", |
|
|
"parenttype":"Contact", |
|
|
"link_doctype":"Lead", |
|
|
"link_doctype":"Lead", |
|
|
"link_name":self.lead_name |
|
|
"link_name":self.lead_name |
|
|
}, fields=["parent as name"]) |
|
|
}, fields=["parent as name"]) |
|
|
|
|
|
|
|
|
|
|
|
for contact_name in contact_names: |
|
|
|
|
|
contact = frappe.get_doc('Contact', contact_name.get('name')) |
|
|
|
|
|
if not contact.has_link('Customer', self.name): |
|
|
|
|
|
contact.append('links', dict(link_doctype='Customer', link_name=self.name)) |
|
|
|
|
|
contact.save(ignore_permissions=self.flags.ignore_permissions) |
|
|
|
|
|
|
|
|
|
|
|
else: |
|
|
for contact_name in contact_names: |
|
|
|
|
|
contact = frappe.get_doc('Contact', contact_name.get('name')) |
|
|
|
|
|
if not contact.has_link('Customer', self.name): |
|
|
|
|
|
contact.append('links', dict(link_doctype='Customer', link_name=self.name)) |
|
|
|
|
|
contact.save(ignore_permissions=self.flags.ignore_permissions) |
|
|
|
|
|
|
|
|
|
|
|
if not contact_names: |
|
|
lead.lead_name = lead.lead_name.lstrip().split(" ") |
|
|
lead.lead_name = lead.lead_name.lstrip().split(" ") |
|
|
lead.first_name = lead.lead_name[0] |
|
|
lead.first_name = lead.lead_name[0] |
|
|
lead.last_name = " ".join(lead.lead_name[1:]) |
|
|
lead.last_name = " ".join(lead.lead_name[1:]) |
|
|