Skip to content

Commit

Permalink
[IMP] Allow su to set crm.lead date_closed manually.
Browse files Browse the repository at this point in the history
This aids import from external systems.
  • Loading branch information
amh-mw committed Jun 6, 2024
1 parent 4e53ef2 commit 1eaaae4
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions addons/crm/models/crm_lead.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,13 +709,14 @@ def write(self, vals):
vals.update({'probability': 100, 'automated_probability': 100})
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 or not self.env.su:
# stage change with new stage: update 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 any(field in ['active', 'stage_id'] for field in vals):
self._handle_won_lost(vals)
Expand Down

0 comments on commit 1eaaae4

Please sign in to comment.