From d0d67bf2ad72458454e9cc93891ec292381761ec Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Wed, 2 Jul 2025 15:58:12 +0530 Subject: [PATCH] fix: update default probability from deal status (cherry picked from commit c96e5ff6c58ca991aca8f705114317e96beb5d42) --- crm/fcrm/doctype/crm_deal/crm_deal.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crm/fcrm/doctype/crm_deal/crm_deal.py b/crm/fcrm/doctype/crm_deal/crm_deal.py index 3022e6a7..6e056ffe 100644 --- a/crm/fcrm/doctype/crm_deal/crm_deal.py +++ b/crm/fcrm/doctype/crm_deal/crm_deal.py @@ -142,8 +142,16 @@ class CRMDeal(Document): if self.status == "Won" and not self.close_date: self.close_date = frappe.utils.nowdate() + def update_default_probability(self): + """ + Update the default probability based on the status. + """ + if not self.probability or self.probability == 0: + self.probability = frappe.db.get_value("CRM Deal Status", self.status, "probability") or 0 + def validate_forcasting_fields(self): self.update_close_date() + self.update_default_probability() if frappe.db.get_single_value("FCRM Settings", "enable_forecasting"): if not self.deal_value or self.deal_value == 0: frappe.throw(_("Deal Value is required."), frappe.MandatoryError)