From bcfe4b6a4991c731f40f1a17fbf3454b1879ffc8 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Sat, 5 Jul 2025 12:30:40 +0530 Subject: [PATCH 1/4] fix: made mobile_no, email & phone readonly since it captures primary contacts data --- crm/fcrm/doctype/crm_deal/crm_deal.json | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/crm/fcrm/doctype/crm_deal/crm_deal.json b/crm/fcrm/doctype/crm_deal/crm_deal.json index 6b7ce0fe..1f9f604f 100644 --- a/crm/fcrm/doctype/crm_deal/crm_deal.json +++ b/crm/fcrm/doctype/crm_deal/crm_deal.json @@ -130,14 +130,16 @@ { "fieldname": "email", "fieldtype": "Data", - "label": "Email", - "options": "Email" + "label": "Primary Email", + "options": "Email", + "read_only": 1 }, { "fieldname": "mobile_no", "fieldtype": "Data", - "label": "Mobile No", - "options": "Phone" + "label": "Primary Mobile No", + "options": "Phone", + "read_only": 1 }, { "default": "Qualification", @@ -250,8 +252,9 @@ { "fieldname": "phone", "fieldtype": "Data", - "label": "Phone", - "options": "Phone" + "label": "Primary Phone", + "options": "Phone", + "read_only": 1 }, { "fieldname": "log_tab", @@ -411,7 +414,7 @@ "grid_page_length": 50, "index_web_pages_for_search": 1, "links": [], - "modified": "2025-07-02 11:07:50.192089", + "modified": "2025-07-05 12:25:05.927806", "modified_by": "Administrator", "module": "FCRM", "name": "CRM Deal", From 96200aebe607ecfdabfcb0a4f0ea7dfa4beab213 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Sat, 5 Jul 2025 13:21:21 +0530 Subject: [PATCH 2/4] fix: update primary mobile_no & email in deal if contact is updated --- crm/api/contact.py | 13 +++++++++---- crm/fcrm/doctype/crm_deal/api.py | 18 +++--------------- crm/fcrm/doctype/crm_lead/api.py | 2 +- 3 files changed, 13 insertions(+), 20 deletions(-) diff --git a/crm/api/contact.py b/crm/api/contact.py index 6a812d5f..acf7227a 100644 --- a/crm/api/contact.py +++ b/crm/api/contact.py @@ -14,11 +14,16 @@ def update_deals_email_mobile_no(doc): ) 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: - deal.email = doc.email_id - deal.mobile_no = doc.mobile_no - deal.save(ignore_permissions=True) + frappe.db.set_value( + "CRM Deal", + linked_deal.parent, + { + "email": doc.email_id, + "mobile_no": doc.mobile_no, + }, + ) @frappe.whitelist() diff --git a/crm/fcrm/doctype/crm_deal/api.py b/crm/fcrm/doctype/crm_deal/api.py index dd5d76df..499d48ac 100644 --- a/crm/fcrm/doctype/crm_deal/api.py +++ b/crm/fcrm/doctype/crm_deal/api.py @@ -1,6 +1,6 @@ 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 @@ -32,24 +32,12 @@ def get_deal_contacts(name): is_primary = contact.is_primary 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 = { "name": contact.name, "image": contact.image, "full_name": contact.full_name, - "email": get_primary_email(contact), - "mobile_no": get_primary_mobile_no(contact), + "email": contact.email_id, + "mobile_no": contact.mobile_no, "is_primary": is_primary, } deal_contacts.append(_contact) diff --git a/crm/fcrm/doctype/crm_lead/api.py b/crm/fcrm/doctype/crm_lead/api.py index e826e888..cfb89540 100644 --- a/crm/fcrm/doctype/crm_lead/api.py +++ b/crm/fcrm/doctype/crm_lead/api.py @@ -1,6 +1,6 @@ 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 42ea1ad16e45cffab59c0bd6885be1312674e38f Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Sat, 5 Jul 2025 14:09:37 +0530 Subject: [PATCH 3/4] fix: useDocument in contact page --- crm/api/contact.py | 13 -- frontend/src/components/SidePanelLayout.vue | 2 +- frontend/src/pages/Contact.vue | 147 ++++++-------------- frontend/src/pages/MobileContact.vue | 132 ++++++------------ 4 files changed, 86 insertions(+), 208 deletions(-) diff --git a/crm/api/contact.py b/crm/api/contact.py index acf7227a..6d864d7a 100644 --- a/crm/api/contact.py +++ b/crm/api/contact.py @@ -26,19 +26,6 @@ def update_deals_email_mobile_no(doc): ) -@frappe.whitelist() -def get_contact(name): - contact = frappe.get_doc("Contact", name) - contact.check_permission("read") - - contact = contact.as_dict() - - if not len(contact): - frappe.throw(_("Contact not found"), frappe.DoesNotExistError) - - return contact - - @frappe.whitelist() def get_linked_deals(contact): """Get linked deals for a contact""" diff --git a/frontend/src/components/SidePanelLayout.vue b/frontend/src/components/SidePanelLayout.vue index 1bfe6b3a..eac3eec8 100644 --- a/frontend/src/components/SidePanelLayout.vue +++ b/frontend/src/components/SidePanelLayout.vue @@ -125,7 +125,7 @@ />
{{ __('No {0} Available', [field.label]) diff --git a/frontend/src/pages/Contact.vue b/frontend/src/pages/Contact.vue index b77f5ce7..27c9a998 100644 --- a/frontend/src/pages/Contact.vue +++ b/frontend/src/pages/Contact.vue @@ -1,5 +1,5 @@