Rohan Bansal | 76825ab | 2020-04-28 16:08:52 +0530 | [diff] [blame] | 1 | import frappe |
| 2 | |
| 3 | |
| 4 | def update_lead_phone_numbers(contact, method): |
| 5 | if contact.phone_nos: |
| 6 | contact_lead = contact.get_link_for("Lead") |
| 7 | if contact_lead: |
| 8 | phone = mobile_no = contact.phone_nos[0].phone |
| 9 | |
| 10 | if len(contact.phone_nos) > 1: |
| 11 | # get the default phone number |
Rohan Bansal | 7835bf9 | 2020-04-29 13:09:16 +0530 | [diff] [blame] | 12 | primary_phones = [phone_doc.phone for phone_doc in contact.phone_nos if phone_doc.is_primary_phone] |
Rohan Bansal | 76825ab | 2020-04-28 16:08:52 +0530 | [diff] [blame] | 13 | if primary_phones: |
| 14 | phone = primary_phones[0] |
| 15 | |
| 16 | # get the default mobile number |
Rohan Bansal | 7835bf9 | 2020-04-29 13:09:16 +0530 | [diff] [blame] | 17 | primary_mobile_nos = [phone_doc.phone for phone_doc in contact.phone_nos if phone_doc.is_primary_mobile_no] |
Rohan Bansal | 76825ab | 2020-04-28 16:08:52 +0530 | [diff] [blame] | 18 | if primary_mobile_nos: |
| 19 | mobile_no = primary_mobile_nos[0] |
| 20 | |
| 21 | lead = frappe.get_doc("Lead", contact_lead) |
Myuddin khatri | fc0e45d | 2020-05-07 15:11:39 +0530 | [diff] [blame] | 22 | lead.db_set("phone", phone) |
| 23 | lead.db_set("mobile_no", mobile_no) |