diff options
| author | Thibault Delavallée <tde@odoo.com> | 2020-10-15 13:40:21 +0000 |
|---|---|---|
| committer | Thibault Delavallée <tde@odoo.com> | 2021-02-05 10:25:16 +0000 |
| commit | 0182aa1b536244e84f4d3474b6b9f5c3a259ca1e (patch) | |
| tree | 160151a48cbf9f47844ca167adee6479237e2c28 /addons | |
| parent | 4ce59c3ab26a441ad8b7f2fd038b690cf897231d (diff) | |
[FIX] crm: keep order of lead ids when mass converting
Manual backport of odoo/odoo@36c78e3e3ac1ddad024eb4324daf2bd1da80404c
Purpose of this commit is to avoid the use of sets in convert wizard. This set
is used to compute ids of leads to merge and to convert. Using a set make order
impossible to predict. Using lists allows to have reproducible tests notably.
Spotted when working on task ID-2086889
Backported in Task ID-2451339
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/crm/wizard/crm_lead_to_opportunity_mass.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/addons/crm/wizard/crm_lead_to_opportunity_mass.py b/addons/crm/wizard/crm_lead_to_opportunity_mass.py index 0dcc796e5f3..9deb29293e3 100644 --- a/addons/crm/wizard/crm_lead_to_opportunity_mass.py +++ b/addons/crm/wizard/crm_lead_to_opportunity_mass.py @@ -81,6 +81,8 @@ class Lead2OpportunityMassConvert(models.TransientModel): def action_mass_convert(self): self.ensure_one() if self.name == 'convert' and self.deduplicate: + # TDE CLEANME: still using active_ids from context + active_ids = self._context.get('active_ids', []) merged_lead_ids = set() remaining_lead_ids = set() for lead in self.lead_tomerge_ids: @@ -94,10 +96,11 @@ class Lead2OpportunityMassConvert(models.TransientModel): lead = duplicated_leads.merge_opportunity() merged_lead_ids.update(duplicated_leads.ids) remaining_lead_ids.add(lead.id) - active_ids = set(self._context.get('active_ids', {})) - active_ids = (active_ids - merged_lead_ids) | remaining_lead_ids + # rebuild list of lead IDS to convert, following given order + final_ids = [lead_id for lead_id in active_ids if lead_id not in merged_lead_ids] + final_ids += [lead_id for lead_id in remaining_lead_ids if lead_id not in final_ids] - self = self.with_context(active_ids=list(active_ids)) # only update active_ids when there are set + self = self.with_context(active_ids=final_ids) # only update active_ids when there are set return self.action_apply() def _convert_handle_partner(self, lead, action, partner_id): |
