From 2c3a660b99e7cc3a1443d50470b3b773d3a245fc Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Wed, 11 Jun 2025 13:00:02 +0530 Subject: [PATCH 01/11] fix: added deal value field (cherry picked from commit 01f0213693d0885228b852bbf852fff254df988f) --- crm/fcrm/doctype/crm_deal/crm_deal.json | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/crm/fcrm/doctype/crm_deal/crm_deal.json b/crm/fcrm/doctype/crm_deal/crm_deal.json index 67f441c3..10e56be4 100644 --- a/crm/fcrm/doctype/crm_deal/crm_deal.json +++ b/crm/fcrm/doctype/crm_deal/crm_deal.json @@ -11,11 +11,14 @@ "naming_series", "organization", "next_step", - "probability", "column_break_ijan", "status", - "close_date", "deal_owner", + "section_break_jgpm", + "probability", + "deal_value", + "column_break_kpxa", + "close_date", "contacts_tab", "contacts", "contact", @@ -91,7 +94,7 @@ { "fieldname": "close_date", "fieldtype": "Date", - "label": "Close Date" + "label": "Expected Closure Date" }, { "fieldname": "next_step", @@ -374,12 +377,26 @@ "label": "Net Total", "options": "currency", "read_only": 1 + }, + { + "fieldname": "section_break_jgpm", + "fieldtype": "Section Break" + }, + { + "fieldname": "deal_value", + "fieldtype": "Currency", + "label": "Deal Value", + "options": "currency" + }, + { + "fieldname": "column_break_kpxa", + "fieldtype": "Column Break" } ], "grid_page_length": 50, "index_web_pages_for_search": 1, "links": [], - "modified": "2025-05-12 12:30:55.415282", + "modified": "2025-06-11 12:58:22.439045", "modified_by": "Administrator", "module": "FCRM", "name": "CRM Deal", From 1c7ea0b44b8a4cafa0107fdddcb17c6268d17f5c Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Wed, 11 Jun 2025 13:01:22 +0530 Subject: [PATCH 02/11] fix: added probability field in deal status (cherry picked from commit fdca27bb81533b45eac0ba9d45c2ca1d094d2fae) --- .../doctype/crm_deal_status/crm_deal_status.json | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/crm/fcrm/doctype/crm_deal_status/crm_deal_status.json b/crm/fcrm/doctype/crm_deal_status/crm_deal_status.json index b0374ca1..ae026c74 100644 --- a/crm/fcrm/doctype/crm_deal_status/crm_deal_status.json +++ b/crm/fcrm/doctype/crm_deal_status/crm_deal_status.json @@ -8,7 +8,8 @@ "field_order": [ "deal_status", "color", - "position" + "position", + "probability" ], "fields": [ { @@ -32,11 +33,17 @@ "fieldtype": "Int", "in_list_view": 1, "label": "Position" + }, + { + "fieldname": "probability", + "fieldtype": "Percent", + "label": "Probability" } ], + "grid_page_length": 50, "index_web_pages_for_search": 1, "links": [], - "modified": "2024-01-19 21:56:44.552134", + "modified": "2025-06-11 13:00:34.518808", "modified_by": "Administrator", "module": "FCRM", "name": "CRM Deal Status", @@ -68,7 +75,8 @@ "write": 1 } ], + "row_format": "Dynamic", "sort_field": "modified", "sort_order": "DESC", "states": [] -} \ No newline at end of file +} From b0474e87644f7849055cbe300effcfc819c462a5 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Wed, 11 Jun 2025 14:18:25 +0530 Subject: [PATCH 03/11] fix: update and reset value in triggerOnChange method (cherry picked from commit 7d79cbf5bdd664e76fb90b994d0d4f5c257c0ed0) --- frontend/src/components/Controls/Grid.vue | 3 +-- frontend/src/components/FieldLayout/Field.vue | 6 ++---- frontend/src/components/SidePanelLayout.vue | 4 +--- frontend/src/data/document.js | 20 ++++++++++++------- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/frontend/src/components/Controls/Grid.vue b/frontend/src/components/Controls/Grid.vue index 54bc29dc..19240a86 100644 --- a/frontend/src/components/Controls/Grid.vue +++ b/frontend/src/components/Controls/Grid.vue @@ -509,8 +509,7 @@ const deleteRows = () => { } function fieldChange(value, field, row) { - row[field.fieldname] = value - triggerOnChange(field.fieldname, row) + triggerOnChange(field.fieldname, value, row) } function getDefaultValue(defaultValue, fieldtype) { diff --git a/frontend/src/components/FieldLayout/Field.vue b/frontend/src/components/FieldLayout/Field.vue index b517d973..07f530cd 100644 --- a/frontend/src/components/FieldLayout/Field.vue +++ b/frontend/src/components/FieldLayout/Field.vue @@ -332,12 +332,10 @@ const getPlaceholder = (field) => { } function fieldChange(value, df) { - data.value[df.fieldname] = value - if (isGridRow) { - triggerOnChange(df.fieldname, data.value) + triggerOnChange(df.fieldname, value, data.value) } else { - triggerOnChange(df.fieldname) + triggerOnChange(df.fieldname, value) } } diff --git a/frontend/src/components/SidePanelLayout.vue b/frontend/src/components/SidePanelLayout.vue index 3fe8fd1a..b9512b46 100644 --- a/frontend/src/components/SidePanelLayout.vue +++ b/frontend/src/components/SidePanelLayout.vue @@ -489,9 +489,7 @@ function parsedField(field) { async function fieldChange(value, df) { if (props.preview) return - document.doc[df.fieldname] = value - - await triggerOnChange(df.fieldname) + await triggerOnChange(df.fieldname, value) document.save.submit(null, { onSuccess: () => { diff --git a/frontend/src/data/document.js b/frontend/src/data/document.js index 7d456676..76e35a9e 100644 --- a/frontend/src/data/document.js +++ b/frontend/src/data/document.js @@ -117,20 +117,26 @@ export function useDocument(doctype, docname) { await trigger(handler) } - async function triggerOnChange(fieldname, row) { + async function triggerOnChange(fieldname, value, row) { + const oldValue = documentsCache[doctype][docname || ''].doc[fieldname] + documentsCache[doctype][docname || ''].doc[fieldname] = value + const handler = async function () { + this.value = value + this.oldValue = oldValue if (row) { this.currentRowIdx = row.idx - this.value = row[fieldname] - this.oldValue = getOldValue(fieldname, row) - } else { - this.value = documentsCache[doctype][docname || ''].doc[fieldname] - this.oldValue = getOldValue(fieldname) } await this[fieldname]?.() } - await trigger(handler, row) + try { + await trigger(handler, row) + } catch (error) { + documentsCache[doctype][docname || ''].doc[fieldname] = oldValue + console.error(handler) + throw error + } } async function triggerOnRowAdd(row) { From 5fff00338a258472f5c86f5c6f09ca56cf2b6022 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Wed, 11 Jun 2025 14:19:16 +0530 Subject: [PATCH 04/11] fix: added throwError global method (cherry picked from commit 9af300bba8a59cb49ecce26fe5e790fdb646cd99) --- frontend/src/data/script.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/frontend/src/data/script.js b/frontend/src/data/script.js index b809f744..47185bab 100644 --- a/frontend/src/data/script.js +++ b/frontend/src/data/script.js @@ -46,6 +46,11 @@ export function getScript(doctype, view = 'Form') { helpers.router = router helpers.call = call + helpers.throwError = (message) => { + toast.error(message || __('An error occurred')) + throw new Error(message || __('An error occurred')) + } + helpers.crm = { makePhoneCall: makeCall, } From 87a38250f6549d1aef2c102a8323c823f36eedda Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Wed, 11 Jun 2025 14:20:11 +0530 Subject: [PATCH 05/11] fix: trigger on change on status change (cherry picked from commit e9e0aa357b1b1596f57d8bda0037f36514972169) --- frontend/src/components/Modals/DealModal.vue | 4 ++-- frontend/src/components/Modals/LeadModal.vue | 4 ++-- frontend/src/pages/Deal.vue | 14 ++++++++++++-- frontend/src/pages/Lead.vue | 15 ++++++++++----- frontend/src/pages/MobileDeal.vue | 14 ++++++++++++-- frontend/src/pages/MobileLead.vue | 14 ++++++++++++-- frontend/src/stores/statuses.js | 13 +++++++++---- 7 files changed, 59 insertions(+), 19 deletions(-) diff --git a/frontend/src/components/Modals/DealModal.vue b/frontend/src/components/Modals/DealModal.vue index 1c516407..e4ce7419 100644 --- a/frontend/src/components/Modals/DealModal.vue +++ b/frontend/src/components/Modals/DealModal.vue @@ -94,7 +94,7 @@ const show = defineModel() const router = useRouter() const error = ref(null) -const { document: deal } = useDocument('CRM Deal') +const { document: deal, triggerOnChange } = useDocument('CRM Deal') const hasOrganizationSections = ref(true) const hasContactSections = ref(true) @@ -164,7 +164,7 @@ const tabs = createResource({ }) const dealStatuses = computed(() => { - let statuses = statusOptions('deal') + let statuses = statusOptions('deal', null, [], triggerOnChange) if (!deal.doc.status) { deal.doc.status = statuses[0].value } diff --git a/frontend/src/components/Modals/LeadModal.vue b/frontend/src/components/Modals/LeadModal.vue index bf1461d1..1976ad3c 100644 --- a/frontend/src/components/Modals/LeadModal.vue +++ b/frontend/src/components/Modals/LeadModal.vue @@ -70,10 +70,10 @@ const router = useRouter() const error = ref(null) const isLeadCreating = ref(false) -const { document: lead } = useDocument('CRM Lead') +const { document: lead, triggerOnChange } = useDocument('CRM Lead') const leadStatuses = computed(() => { - let statuses = statusOptions('lead') + let statuses = statusOptions('lead', null, [], triggerOnChange) if (!lead.doc.status) { lead.doc.status = statuses?.[0]?.value } diff --git a/frontend/src/pages/Deal.vue b/frontend/src/pages/Deal.vue index e3d09fa7..34e06141 100644 --- a/frontend/src/pages/Deal.vue +++ b/frontend/src/pages/Deal.vue @@ -23,7 +23,14 @@ />