fix: update primary mobile_no & email in deal if contact is updated
This commit is contained in:
parent
bcfe4b6a49
commit
96200aebe6
@ -14,11 +14,16 @@ def update_deals_email_mobile_no(doc):
|
|||||||
)
|
)
|
||||||
|
|
||||||
for linked_deal in linked_deals:
|
for linked_deal in linked_deals:
|
||||||
deal = frappe.get_cached_doc("CRM Deal", linked_deal.parent)
|
deal = frappe.db.get_values("CRM Deal", linked_deal.parent, ["email", "mobile_no"], as_dict=True)[0]
|
||||||
if deal.email != doc.email_id or deal.mobile_no != doc.mobile_no:
|
if deal.email != doc.email_id or deal.mobile_no != doc.mobile_no:
|
||||||
deal.email = doc.email_id
|
frappe.db.set_value(
|
||||||
deal.mobile_no = doc.mobile_no
|
"CRM Deal",
|
||||||
deal.save(ignore_permissions=True)
|
linked_deal.parent,
|
||||||
|
{
|
||||||
|
"email": doc.email_id,
|
||||||
|
"mobile_no": doc.mobile_no,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
from crm.api.doc import get_assigned_users, get_fields_meta
|
from crm.api.doc import get_fields_meta
|
||||||
from crm.fcrm.doctype.crm_form_script.crm_form_script import get_form_script
|
from crm.fcrm.doctype.crm_form_script.crm_form_script import get_form_script
|
||||||
|
|
||||||
|
|
||||||
@ -32,24 +32,12 @@ def get_deal_contacts(name):
|
|||||||
is_primary = contact.is_primary
|
is_primary = contact.is_primary
|
||||||
contact = frappe.get_doc("Contact", contact.contact).as_dict()
|
contact = frappe.get_doc("Contact", contact.contact).as_dict()
|
||||||
|
|
||||||
def get_primary_email(contact):
|
|
||||||
for email in contact.email_ids:
|
|
||||||
if email.is_primary:
|
|
||||||
return email.email_id
|
|
||||||
return contact.email_ids[0].email_id if contact.email_ids else ""
|
|
||||||
|
|
||||||
def get_primary_mobile_no(contact):
|
|
||||||
for phone in contact.phone_nos:
|
|
||||||
if phone.is_primary:
|
|
||||||
return phone.phone
|
|
||||||
return contact.phone_nos[0].phone if contact.phone_nos else ""
|
|
||||||
|
|
||||||
_contact = {
|
_contact = {
|
||||||
"name": contact.name,
|
"name": contact.name,
|
||||||
"image": contact.image,
|
"image": contact.image,
|
||||||
"full_name": contact.full_name,
|
"full_name": contact.full_name,
|
||||||
"email": get_primary_email(contact),
|
"email": contact.email_id,
|
||||||
"mobile_no": get_primary_mobile_no(contact),
|
"mobile_no": contact.mobile_no,
|
||||||
"is_primary": is_primary,
|
"is_primary": is_primary,
|
||||||
}
|
}
|
||||||
deal_contacts.append(_contact)
|
deal_contacts.append(_contact)
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
from crm.api.doc import get_assigned_users, get_fields_meta
|
from crm.api.doc import get_fields_meta
|
||||||
from crm.fcrm.doctype.crm_form_script.crm_form_script import get_form_script
|
from crm.fcrm.doctype.crm_form_script.crm_form_script import get_form_script
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user