From 51530b760830002e9ba3f8bc8cce69d94fd51d9c Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Fri, 11 Jul 2025 16:35:47 +0530 Subject: [PATCH] fix: show lost reason modal if status of type Lost is set --- crm/fcrm/doctype/crm_deal/crm_deal.py | 2 +- frontend/src/pages/Deal.vue | 4 ++-- frontend/src/pages/MobileDeal.vue | 4 ++-- frontend/src/stores/statuses.js | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crm/fcrm/doctype/crm_deal/crm_deal.py b/crm/fcrm/doctype/crm_deal/crm_deal.py index b82f16db..c3a8488d 100644 --- a/crm/fcrm/doctype/crm_deal/crm_deal.py +++ b/crm/fcrm/doctype/crm_deal/crm_deal.py @@ -166,7 +166,7 @@ class CRMDeal(Document): """ Validate the lost reason if the status is set to "Lost". """ - if self.status == "Lost": + if self.status and frappe.get_cached_value("CRM Deal Status", self.status, "type") == "Lost": if not self.lost_reason: frappe.throw(_("Please specify a reason for losing the deal."), frappe.ValidationError) elif self.lost_reason == "Other" and not self.lost_notes: diff --git a/frontend/src/pages/Deal.vue b/frontend/src/pages/Deal.vue index a2d8648f..8ebd5361 100644 --- a/frontend/src/pages/Deal.vue +++ b/frontend/src/pages/Deal.vue @@ -783,7 +783,7 @@ const showLostReasonModal = ref(false) function setLostReason() { if ( - document.doc.status !== 'Lost' || + getDealStatus(document.doc.status).type !== 'Lost' || (document.doc.lost_reason && document.doc.lost_reason !== 'Other') || (document.doc.lost_reason === 'Other' && document.doc.lost_notes) ) { @@ -795,7 +795,7 @@ function setLostReason() { } function beforeStatusChange(data) { - if (data?.hasOwnProperty('status') && data.status == 'Lost') { + if (data?.hasOwnProperty('status') && getDealStatus(data.status).type == 'Lost') { setLostReason() } else { document.save.submit(null, { diff --git a/frontend/src/pages/MobileDeal.vue b/frontend/src/pages/MobileDeal.vue index 9a93f304..5c8e8284 100644 --- a/frontend/src/pages/MobileDeal.vue +++ b/frontend/src/pages/MobileDeal.vue @@ -643,7 +643,7 @@ const showLostReasonModal = ref(false) function setLostReason() { if ( - document.doc.status !== 'Lost' || + getDealStatus(document.doc.status).type !== 'Lost' || (document.doc.lost_reason && document.doc.lost_reason !== 'Other') || (document.doc.lost_reason === 'Other' && document.doc.lost_notes) ) { @@ -655,7 +655,7 @@ function setLostReason() { } function beforeStatusChange(data) { - if (data?.hasOwnProperty('status') && data.status == 'Lost') { + if (data?.hasOwnProperty('status') && getDealStatus(data.status).type == 'Lost') { setLostReason() } else { document.save.submit(null, { diff --git a/frontend/src/stores/statuses.js b/frontend/src/stores/statuses.js index 637c8d2f..9f99b785 100644 --- a/frontend/src/stores/statuses.js +++ b/frontend/src/stores/statuses.js @@ -28,7 +28,7 @@ export const statusesStore = defineStore('crm-statuses', () => { const dealStatuses = createListResource({ doctype: 'CRM Deal Status', - fields: ['name', 'color', 'position'], + fields: ['name', 'color', 'position', 'type'], orderBy: 'position asc', cache: 'deal-statuses', initialData: [],