From aaa1f6c2370c23f30038680c99ecefa1280017f1 Mon Sep 17 00:00:00 2001 From: Dharmraj Jhala Date: Wed, 14 Oct 2020 08:31:21 +0000 Subject: [PATCH] [FIX] crm: update 'Default Values' on alias while updating sales team Whenever when change the 'Leads' of 'Pipeline' boolean field on sales team, it should also update the linked alias. Mainly, if 'Lead' is checked, the 'Default Values' on the alias should also be updated. It used to work before a recent refactoring (see commit [1] and [2] for more information). This commit adapts the changes done in refacotring and updates the alias values while updating the sales team. [1] - https://github.com/odoo/odoo/commit/7cfd364db54e88970ef51c798df3bd4df44222b3 [2] - https://github.com/odoo/odoo/commit/186cfb5ebd35d572d0f635cd7975de7cff0d1055 TaskId - 2357573 closes odoo/odoo#60008 X-original-commit: 0669ee36e195e8e0f98131219b59fcc5cba4cea7 Signed-off-by: Thibault Delavallee (tde) --- addons/crm/models/crm_team.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/addons/crm/models/crm_team.py b/addons/crm/models/crm_team.py index 3b142f48972..cbdad2f0400 100644 --- a/addons/crm/models/crm_team.py +++ b/addons/crm/models/crm_team.py @@ -95,7 +95,12 @@ class Team(models.Model): def write(self, vals): result = super(Team, self).write(vals) if 'use_leads' in vals or 'use_opportunities' in vals: - self.filtered(lambda team: not team.use_leads and not team.use_opportunities).alias_name = False + for team in self: + alias_vals = team._alias_get_creation_values() + team.write({ + 'alias_name': alias_vals.get('alias_name', team.alias_name), + 'alias_defaults': alias_vals.get('alias_defaults'), + }) return result # ------------------------------------------------------------