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", "status",
"deal_owner", "deal_owner",
"lost_reason", "lost_reason",
"other_lost_reason",
"section_break_jgpm", "section_break_jgpm",
"probability", "probability",
"deal_value", "deal_value",
@ -397,13 +398,21 @@
"fieldname": "lost_reason", "fieldname": "lost_reason",
"fieldtype": "Link", "fieldtype": "Link",
"label": "Lost Reason", "label": "Lost Reason",
"mandatory_depends_on": "eval: doc.status == \"Lost\"",
"options": "CRM Lost Reason" "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, "grid_page_length": 50,
"index_web_pages_for_search": 1, "index_web_pages_for_search": 1,
"links": [], "links": [],
"modified": "2025-06-30 17:40:28.673539", "modified": "2025-06-30 17:53:23.408301",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "FCRM", "module": "FCRM",
"name": "CRM Deal", "name": "CRM Deal",

View File

@ -25,6 +25,7 @@ class CRMDeal(Document):
if self.has_value_changed("status"): if self.has_value_changed("status"):
add_status_change_log(self) add_status_change_log(self)
self.validate_forcasting_fields() self.validate_forcasting_fields()
self.validate_lost_reason()
def after_insert(self): def after_insert(self):
if self.deal_owner: if self.deal_owner:
@ -149,6 +150,16 @@ class CRMDeal(Document):
if not self.close_date: if not self.close_date:
frappe.throw(_("Close Date is required."), frappe.MandatoryError) 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 @staticmethod
def default_list_data(): def default_list_data():
columns = [ columns = [