brotherton-erpnext/erpnext/crm/utils.py

24 lines
763 B
Python
Raw Normal View History

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
2020-04-29 07:39:16 +00:00
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
2020-04-29 07:39:16 +00:00
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)
2020-05-07 09:41:39 +00:00
lead.db_set("phone", phone)
lead.db_set("mobile_no", mobile_no)