From 24b3cf63ff596a57022465bf01406b8c07d7a2e7 Mon Sep 17 00:00:00 2001 From: Adrian Torres Date: Mon, 6 Apr 2020 13:07:43 +0000 Subject: [PATCH] [FIX] crm: make crm.team.write work in batch again When `_synchronize_alias` was introduced into crm.team.write, the write method become incompatible with batch writes because `_synchronize_alias` assumes `self` is a recordset of length 1 and performs attribute accesses directly on self, this makes the __get__ crash because it performs a `self.ensure_one()` With this commit, crm.team.write will iterate over the self recordset and call `_synchronize_alias` on every record of the recordset. This also solves a uninstallation problem in sale_crm because a write is performed on crm.team in an uninstall_hook. closes odoo/odoo#49088 X-original-commit: a9511cd42be365e58371d717b8197aac644eaf33 Signed-off-by: Raphael Collet (rco) Signed-off-by: Adrian Torres (adt) --- addons/crm/models/crm_team.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/addons/crm/models/crm_team.py b/addons/crm/models/crm_team.py index a02b7f34433..25b1965de97 100644 --- a/addons/crm/models/crm_team.py +++ b/addons/crm/models/crm_team.py @@ -108,9 +108,8 @@ class Team(models.Model): for team in self: team.alias_id.write(team.get_alias_values()) if 'use_leads' in vals or 'use_opportunities' in vals: - alias_values = self._synchronize_alias(vals) - if alias_values: - self.write(alias_values) + for team in self: + team.write(team._synchronize_alias(vals)) return result def _synchronize_alias(self, values):