[IMP] crm: restore default stage probably when restoring leads

Purpose of this commit is to avoid having restored leads and opportunities
having always 0 probability even if the stage has an high probably than
that.

This commit is linked to task ID 1880051 and PR #26977.
This commit is contained in:
Thibault Delavallée
2018-09-21 11:22:01 +02:00
parent 0627ca78fb
commit 22e33a7a3d
+8
View File
@@ -451,6 +451,14 @@ class Lead(models.Model):
'context': {'default_type': 'opportunity'}
}
def toggle_active(self):
""" When re-activating leads and opportunities set their probability
to the default stage one. """
res = super(Lead, self).toggle_active()
for lead in self.filtered(lambda lead: lead.active and lead.stage_id.probability):
lead.probability = lead.stage_id.probability
return res
# ----------------------------------------
# Business Methods
# ----------------------------------------