fix: made deal value mandatory if forecasting is enabled
This commit is contained in:
parent
4d3fe722e8
commit
4f58aa110a
@ -24,7 +24,7 @@ class CRMDeal(Document):
|
|||||||
self.assign_agent(self.deal_owner)
|
self.assign_agent(self.deal_owner)
|
||||||
if self.has_value_changed("status"):
|
if self.has_value_changed("status"):
|
||||||
add_status_change_log(self)
|
add_status_change_log(self)
|
||||||
self.update_close_date()
|
self.validate_forcasting_fields()
|
||||||
|
|
||||||
def after_insert(self):
|
def after_insert(self):
|
||||||
if self.deal_owner:
|
if self.deal_owner:
|
||||||
@ -141,6 +141,14 @@ class CRMDeal(Document):
|
|||||||
if self.status == "Won" and not self.close_date:
|
if self.status == "Won" and not self.close_date:
|
||||||
self.close_date = frappe.utils.nowdate()
|
self.close_date = frappe.utils.nowdate()
|
||||||
|
|
||||||
|
def validate_forcasting_fields(self):
|
||||||
|
self.update_close_date()
|
||||||
|
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)
|
||||||
|
if not self.close_date:
|
||||||
|
frappe.throw(_("Close Date is required."), frappe.MandatoryError)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def default_list_data():
|
def default_list_data():
|
||||||
columns = [
|
columns = [
|
||||||
|
|||||||
@ -60,7 +60,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"default": "0",
|
"default": "0",
|
||||||
"description": "It will make deal's \"Expected Closure Date\" mandatory to get accurate forecasting insights",
|
"description": "It will make deal's \"Close Date\" & \"Deal Value\" mandatory to get accurate forecasting insights",
|
||||||
"fieldname": "enable_forecasting",
|
"fieldname": "enable_forecasting",
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"label": "Enable Forecasting"
|
"label": "Enable Forecasting"
|
||||||
@ -69,7 +69,7 @@
|
|||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"issingle": 1,
|
"issingle": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2025-06-11 19:12:16.762499",
|
"modified": "2025-07-01 13:20:48.757603",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "FCRM",
|
"module": "FCRM",
|
||||||
"name": "FCRM Settings",
|
"name": "FCRM Settings",
|
||||||
|
|||||||
@ -39,6 +39,11 @@ class FCRMSettings(Document):
|
|||||||
"reqd",
|
"reqd",
|
||||||
"close_date",
|
"close_date",
|
||||||
)
|
)
|
||||||
|
delete_property_setter(
|
||||||
|
"CRM Deal",
|
||||||
|
"reqd",
|
||||||
|
"deal_value",
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
make_property_setter(
|
make_property_setter(
|
||||||
"CRM Deal",
|
"CRM Deal",
|
||||||
@ -47,6 +52,13 @@ class FCRMSettings(Document):
|
|||||||
1 if self.enable_forecasting else 0,
|
1 if self.enable_forecasting else 0,
|
||||||
"Check",
|
"Check",
|
||||||
)
|
)
|
||||||
|
make_property_setter(
|
||||||
|
"CRM Deal",
|
||||||
|
"deal_value",
|
||||||
|
"reqd",
|
||||||
|
1 if self.enable_forecasting else 0,
|
||||||
|
"Check",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_standard_dropdown_items():
|
def get_standard_dropdown_items():
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user