fix: update default probability from deal status

(cherry picked from commit c96e5ff6c58ca991aca8f705114317e96beb5d42)
This commit is contained in:
Shariq Ansari 2025-07-02 15:58:12 +05:30 committed by Mergify
parent 5f459f58cb
commit d0d67bf2ad

View File

@ -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)