From a4d3852c0ed894b118e1f2d48e607dd3e9d28fc1 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Tue, 16 Sep 2025 17:46:17 +0530 Subject: [PATCH] feat: Auto update expected deal value based on products value (cherry picked from commit 7e21a5fee206723cf714f7a8732bb8929aaa57df) --- crm/fcrm/doctype/crm_deal/crm_deal.py | 16 ++++++++++++++-- .../components/Settings/ForecastingSettings.vue | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/crm/fcrm/doctype/crm_deal/crm_deal.py b/crm/fcrm/doctype/crm_deal/crm_deal.py index 6bc2e020..2bf3d8d4 100644 --- a/crm/fcrm/doctype/crm_deal/crm_deal.py +++ b/crm/fcrm/doctype/crm_deal/crm_deal.py @@ -25,7 +25,7 @@ class CRMDeal(Document): add_status_change_log(self) if frappe.db.get_value("CRM Deal Status", self.status, "type") == "Won": self.closed_date = frappe.utils.nowdate() - self.validate_forcasting_fields() + self.validate_forecasting_fields() self.validate_lost_reason() self.update_exchange_rate() @@ -151,9 +151,21 @@ class CRMDeal(Document): 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): + def update_expected_deal_value(self): + """ + Update the expected deal value based on the net total or total. + """ + if ( + frappe.db.get_single_value("FCRM Settings", "auto_update_expected_deal_value") + and (self.net_total or self.total) + and self.expected_deal_value + ): + self.expected_deal_value = self.net_total or self.total + + def validate_forecasting_fields(self): self.update_closed_date() self.update_default_probability() + self.update_expected_deal_value() if frappe.db.get_single_value("FCRM Settings", "enable_forecasting"): if not self.expected_deal_value or self.expected_deal_value == 0: frappe.throw(_("Expected Deal Value is required."), frappe.MandatoryError) diff --git a/frontend/src/components/Settings/ForecastingSettings.vue b/frontend/src/components/Settings/ForecastingSettings.vue index 8b681926..6c765ab7 100644 --- a/frontend/src/components/Settings/ForecastingSettings.vue +++ b/frontend/src/components/Settings/ForecastingSettings.vue @@ -5,7 +5,7 @@ {{ __('Forecasting') }}

- {{ __('Configure forecasting settings for your CRM') }} + {{ __('Configure forecasting feature to help predict sales performance and growth') }}