summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorAdrian Torres <adt@odoo.com>2020-04-06 13:07:43 +0000
committerAdrian Torres <adt@odoo.com>2020-04-06 16:18:02 +0000
commit24b3cf63ff596a57022465bf01406b8c07d7a2e7 (patch)
tree02789ccaa14df1757679f114e5245c96651996d7 /addons
parentd997aa1574e43beb58d95cab4574029bbc8f7b8e (diff)
[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) <rco@openerp.com> Signed-off-by: Adrian Torres (adt) <adt@odoo.com>
Diffstat (limited to 'addons')
-rw-r--r--addons/crm/models/crm_team.py5
1 files 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):