Skip to content

Commit

Permalink
[IMP] Allow crm.lead date_closed to be set manually.
Browse files Browse the repository at this point in the history
  • Loading branch information
amh-mw committed Jun 4, 2024
1 parent 4e53ef2 commit a70e0b5
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions addons/crm/models/crm_lead.py
Original file line number Diff line number Diff line change
Expand Up @@ -710,12 +710,13 @@ def write(self, vals):
stage_is_won = True

# stage change with new stage: update probability and date_closed
if vals.get('probability', 0) >= 100 or not vals.get('active', True):
vals['date_closed'] = fields.Datetime.now()
elif vals.get('probability', 0) > 0:
vals['date_closed'] = False
elif stage_updated and not stage_is_won and not 'probability' in vals:
vals['date_closed'] = False
if 'date_closed' not in vals:
if vals.get('probability', 0) >= 100 or not vals.get('active', True):
vals['date_closed'] = fields.Datetime.now()
elif vals.get('probability', 0) > 0:
vals['date_closed'] = False
elif stage_updated and not stage_is_won and not 'probability' in vals:
vals['date_closed'] = False

if any(field in ['active', 'stage_id'] for field in vals):
self._handle_won_lost(vals)
Expand Down

0 comments on commit a70e0b5

Please sign in to comment.