fix: show lost reason modal if status of type Lost is set
This commit is contained in:
parent
4e6d4a1d77
commit
51530b7608
@ -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:
|
||||
|
||||
@ -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, {
|
||||
|
||||
@ -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, {
|
||||
|
||||
@ -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: [],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user