diff --git a/crm/fcrm/doctype/crm_deal/crm_deal.py b/crm/fcrm/doctype/crm_deal/crm_deal.py index b650301e..b7e4ec83 100644 --- a/crm/fcrm/doctype/crm_deal/crm_deal.py +++ b/crm/fcrm/doctype/crm_deal/crm_deal.py @@ -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 = [