Merge pull request #21471 from Alchez/dev-update-lead-contact
fix: update lead if contact details are changed (develop)
This commit is contained in:
commit
c9a6f37199
24
erpnext/crm/utils.py
Normal file
24
erpnext/crm/utils.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import frappe
|
||||||
|
|
||||||
|
|
||||||
|
def update_lead_phone_numbers(contact, method):
|
||||||
|
if contact.phone_nos:
|
||||||
|
contact_lead = contact.get_link_for("Lead")
|
||||||
|
if contact_lead:
|
||||||
|
phone = mobile_no = contact.phone_nos[0].phone
|
||||||
|
|
||||||
|
if len(contact.phone_nos) > 1:
|
||||||
|
# get the default phone number
|
||||||
|
primary_phones = [phone_doc.phone for phone_doc in contact.phone_nos if phone_doc.is_primary_phone]
|
||||||
|
if primary_phones:
|
||||||
|
phone = primary_phones[0]
|
||||||
|
|
||||||
|
# get the default mobile number
|
||||||
|
primary_mobile_nos = [phone_doc.phone for phone_doc in contact.phone_nos if phone_doc.is_primary_mobile_no]
|
||||||
|
if primary_mobile_nos:
|
||||||
|
mobile_no = primary_mobile_nos[0]
|
||||||
|
|
||||||
|
lead = frappe.get_doc("Lead", contact_lead)
|
||||||
|
lead.phone = phone
|
||||||
|
lead.mobile_no = mobile_no
|
||||||
|
lead.save()
|
@ -250,7 +250,8 @@ doc_events = {
|
|||||||
},
|
},
|
||||||
"Contact": {
|
"Contact": {
|
||||||
"on_trash": "erpnext.support.doctype.issue.issue.update_issue",
|
"on_trash": "erpnext.support.doctype.issue.issue.update_issue",
|
||||||
"after_insert": "erpnext.communication.doctype.call_log.call_log.set_caller_information"
|
"after_insert": "erpnext.communication.doctype.call_log.call_log.set_caller_information",
|
||||||
|
"validate": "erpnext.crm.utils.update_lead_phone_numbers"
|
||||||
},
|
},
|
||||||
"Lead": {
|
"Lead": {
|
||||||
"after_insert": "erpnext.communication.doctype.call_log.call_log.set_caller_information"
|
"after_insert": "erpnext.communication.doctype.call_log.call_log.set_caller_information"
|
||||||
@ -537,4 +538,4 @@ global_search_doctypes = {
|
|||||||
{'doctype': 'Hotel Room Package', 'index': 3},
|
{'doctype': 'Hotel Room Package', 'index': 3},
|
||||||
{'doctype': 'Hotel Room Type', 'index': 4}
|
{'doctype': 'Hotel Room Type', 'index': 4}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user