fix: set close date to now if status is Won

(cherry picked from commit a98b0e3a009f028c86ebb87385136ad0ab711a81)
This commit is contained in:
Shariq Ansari 2025-06-13 14:20:50 +05:30 committed by Mergify
parent d06f749544
commit e9362a50eb

View File

@ -24,6 +24,7 @@ class CRMDeal(Document):
self.assign_agent(self.deal_owner)
if self.has_value_changed("status"):
add_status_change_log(self)
self.update_close_date()
def after_insert(self):
if self.deal_owner:
@ -133,6 +134,13 @@ class CRMDeal(Document):
if sla:
sla.apply(self)
def update_close_date(self):
"""
Update the close date based on the "Won" status.
"""
if self.status == "Won" and not self.close_date:
self.close_date = frappe.utils.nowdate()
@staticmethod
def default_list_data():
columns = [