fix: show lost reason modal if status of type Lost is set

(cherry picked from commit 51530b760830002e9ba3f8bc8cce69d94fd51d9c)
This commit is contained in:
Shariq Ansari 2025-07-11 16:35:47 +05:30 committed by Mergify
parent f7bcc4b910
commit d52ee6653c
4 changed files with 6 additions and 6 deletions

View File

@ -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:

View File

@ -773,7 +773,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)
) {
@ -785,7 +785,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, {

View File

@ -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, {

View File

@ -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: [],