From 92d728072843b1449cb2e2e626cde7a218e68530 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Tue, 1 Jul 2025 16:53:40 +0530 Subject: [PATCH] chore: resolved conflict --- crm/fcrm/doctype/crm_deal/crm_deal.json | 11 ++++++++++- crm/fcrm/doctype/crm_deal/crm_deal.py | 11 +++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/crm/fcrm/doctype/crm_deal/crm_deal.json b/crm/fcrm/doctype/crm_deal/crm_deal.json index 6344d6d9..121c5e95 100644 --- a/crm/fcrm/doctype/crm_deal/crm_deal.json +++ b/crm/fcrm/doctype/crm_deal/crm_deal.json @@ -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", diff --git a/crm/fcrm/doctype/crm_deal/crm_deal.py b/crm/fcrm/doctype/crm_deal/crm_deal.py index 9afab159..97b09523 100644 --- a/crm/fcrm/doctype/crm_deal/crm_deal.py +++ b/crm/fcrm/doctype/crm_deal/crm_deal.py @@ -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 = [