1
0
forked from test/crm

chore: resolved conflict

(cherry picked from commit 92d728072843b1449cb2e2e626cde7a218e68530)
This commit is contained in:
Shariq Ansari 2025-07-01 16:53:40 +05:30 committed by Mergify
parent 252fe05edc
commit 6aa4a03b0f
2 changed files with 21 additions and 1 deletions

View File

@ -15,6 +15,7 @@
"status",
"deal_owner",
"lost_reason",
"other_lost_reason",
"section_break_jgpm",
"probability",
"deal_value",
@ -397,13 +398,21 @@
"fieldname": "lost_reason",
"fieldtype": "Link",
"label": "Lost Reason",
"mandatory_depends_on": "eval: doc.status == \"Lost\"",
"options": "CRM Lost Reason"
},
{
"depends_on": "eval: doc.lost_reason == \"Other\"",
"fieldname": "other_lost_reason",
"fieldtype": "Data",
"label": "Specify Other Reason",
"mandatory_depends_on": "eval: doc.lost_reason == \"Other\""
}
],
"grid_page_length": 50,
"index_web_pages_for_search": 1,
"links": [],
"modified": "2025-06-30 17:40:28.673539",
"modified": "2025-06-30 17:53:23.408301",
"modified_by": "Administrator",
"module": "FCRM",
"name": "CRM Deal",

View File

@ -25,6 +25,7 @@ class CRMDeal(Document):
if self.has_value_changed("status"):
add_status_change_log(self)
self.validate_forcasting_fields()
self.validate_lost_reason()
def after_insert(self):
if self.deal_owner:
@ -149,6 +150,16 @@ class CRMDeal(Document):
if not self.close_date:
frappe.throw(_("Close Date is required."), frappe.MandatoryError)
def validate_lost_reason(self):
"""
Validate the lost reason if the status is set to "Lost".
"""
if self.status == "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.other_lost_reason:
frappe.throw(_("Please specify the reason for losing the deal."), frappe.ValidationError)
@staticmethod
def default_list_data():
columns = [