From 9b534649d5a223523895f1440a359b3ef9529dff Mon Sep 17 00:00:00 2001 From: Florent Lejoly Date: Fri, 8 Nov 2019 09:59:10 +0000 Subject: [PATCH] [FIX] crm: fix archive / restore PLS inconsistencies SPECIFICATIONS Fixes following issue: when a lead is marked as lost, the probability is correctly set to 0 but not the automatic one. If one clicks on the "Set to automatic", the probability is updated, which un-archives it without really restoring it, meaning we get in a very strange state outside the expected flow (no Won/Lost buttons, ...). With this commit the automated probability is set to 0 when setting as lost. Moreover restoring a lead recomputes its probabilities. LINKS Task ID 2092799 Manual backport of PR odoo/odoo#42015 done in master PR odoo/odoo#42045 closes odoo/odoo#42057 X-original-commit: 9ac5f42cd0c381bdddfd196721983057bab7028b Signed-off-by: Thibault Delavallee (tde) --- addons/crm/models/crm_lead.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/addons/crm/models/crm_lead.py b/addons/crm/models/crm_lead.py index 0d09d496aa5..afcb81a8426 100644 --- a/addons/crm/models/crm_lead.py +++ b/addons/crm/models/crm_lead.py @@ -538,6 +538,11 @@ class Lead(models.Model): self.filtered(lambda lead: lead.active)._compute_probabilities() return True + def toggle_active(self): + res = super(Lead, self).toggle_active() + self.filtered(lambda lead: lead.active)._compute_probabilities() + return res + def _rebuild_pls_frequency_table_threshold(self): """ Called by action_set_lost and action_set_won. Will run the cron to update the frequency table only if the number of lead is above