Skip to content

Commit

Permalink
feat: set lead name from email
Browse files Browse the repository at this point in the history
(cherry picked from commit ceeb724)

# Conflicts:
#	erpnext/crm/doctype/lead/lead.json
  • Loading branch information
barredterra authored and mergify[bot] committed Dec 14, 2023
1 parent 73d525e commit 1469ca7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions erpnext/crm/doctype/lead/lead.json
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,11 @@
"idx": 5,
"image_field": "image",
"links": [],
<<<<<<< HEAD
"modified": "2022-10-13 12:42:04.277879",
=======
"modified": "2023-12-01 18:46:49.468526",
>>>>>>> ceeb724acc (feat: set lead name from email)
"modified_by": "Administrator",
"module": "CRM",
"name": "Lead",
Expand Down Expand Up @@ -576,6 +580,7 @@
],
"search_fields": "lead_name,lead_owner,status",
"sender_field": "email_id",
"sender_name_field": "lead_name",
"show_name_in_global_search": 1,
"sort_field": "modified",
"sort_order": "DESC",
Expand Down
5 changes: 5 additions & 0 deletions erpnext/crm/doctype/lead/lead.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from erpnext.accounts.party import set_taxes
from erpnext.controllers.selling_controller import SellingController
from erpnext.crm.utils import CRMNote, copy_comments, link_communications, link_open_events
from erpnext.selling.doctype.customer.customer import parse_full_name


class Lead(SellingController, CRMNote):
Expand Down Expand Up @@ -48,6 +49,10 @@ def before_insert(self):
return
self.contact_doc = self.create_contact()

# leads created by email inbox only have the full name set
if self.lead_name and not any([self.first_name, self.middle_name, self.last_name]):
self.first_name, self.middle_name, self.last_name = parse_full_name(self.lead_name)

def after_insert(self):
self.link_to_contact()

Expand Down

0 comments on commit 1469ca7

Please sign in to comment.