[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) <tde@openerp.com>
This commit is contained in:
Dharmraj Jhala
2020-10-14 14:26:57 +00:00
parent 461c3fa91b
commit aaa1f6c237
+6 -1
View File
@@ -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
# ------------------------------------------------------------