From 04bfd54013cd26d95332641789b4e2b294c4b3b5 Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Mon, 4 Dec 2017 16:59:07 +0100 Subject: [PATCH] [FIX] sales_team: multicompany issue typo 3ad1867e 3ad1867e could lead to wrong results in a multicompany setting because the change got the company from the lead but it was intended to be gotten from the user. Since ('company_id', 'child_of', False) returned "root" companies, the code still got a sales team but possibly one from another company if the user was on another company that its sales team. This would lead to an access issue that this commit solves. opw-784455 closes #21428 --- addons/sales_team/models/crm_team.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/sales_team/models/crm_team.py b/addons/sales_team/models/crm_team.py index 2eebdd5eceb..ae491e7866e 100644 --- a/addons/sales_team/models/crm_team.py +++ b/addons/sales_team/models/crm_team.py @@ -19,7 +19,7 @@ class CrmTeam(models.Model): if 'default_team_id' in self.env.context: team_id = self.env['crm.team'].browse(self.env.context.get('default_team_id')) if not team_id or not team_id.exists(): - company_id = self.sudo(user_id).company_id.id + company_id = self.sudo(user_id).env.user.company_id.id team_id = self.env['crm.team'].sudo().search([ '|', ('user_id', '=', user_id), ('member_ids', '=', user_id), '|', ('company_id', '=', False), ('company_id', 'child_of', [company_id])