Merge pull request #38751 from frappe/mergify/bp/version-14-hotfix/pr-38505

feat: set lead name from email (#38505)
This commit is contained in:
Deepesh Garg
2023-12-16 22:29:43 +05:30
committed by GitHub
2 changed files with 8 additions and 2 deletions

View File

@@ -514,7 +514,7 @@
"idx": 5,
"image_field": "image",
"links": [],
"modified": "2022-10-13 12:42:04.277879",
"modified": "2023-12-01 18:46:49.468526",
"modified_by": "Administrator",
"module": "CRM",
"name": "Lead",
@@ -576,10 +576,11 @@
],
"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",
"states": [],
"subject_field": "title",
"title_field": "title"
}
}

View File

@@ -14,6 +14,7 @@ from frappe.utils import comma_and, get_link_to_form, has_gravatar, validate_ema
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):
@@ -48,6 +49,10 @@ class Lead(SellingController, CRMNote):
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()