[FIX] sale,sales_team: set lead team when creating quotation
Steps to reproduce: -Install sales and crm -Apply multiteam option in crm settings -Create a user with two teams A and B -Create with this user a lead with team B -From this lead create a quotation Current behavior: The quotation could have team A (the team of the lead is ignored) Expected behavior: The quotation always has team B Problem when creating the quotation the team id is not propagated in the context to the final function _get_default_team_id and in this function the default context team is only check if no teams have been found for the user, so the function always selects the first team of the user. To solve the issue we propagate the team id to the default function and we change it so that if the context default team is in the user teams it is this one that is going to be selected and no other. opw-2830913 X-original-commit: 0b6c63f2be90928f5d6806ef489c369a1310be04 Part-of: odoo/odoo#94045
This commit is contained in:
@@ -409,7 +409,7 @@ class SaleOrder(models.Model):
|
||||
def _compute_team_id(self):
|
||||
cached_teams = {}
|
||||
for order in self:
|
||||
default_team_id = (order.team_id or order.partner_id.team_id).id
|
||||
default_team_id = self.env.context.get('default_team_id', False) or order.team_id.id or order.partner_id.team_id.id
|
||||
user_id = order.user_id.id
|
||||
company_id = order.company_id.id
|
||||
key = (default_team_id, user_id, company_id)
|
||||
|
||||
@@ -66,6 +66,7 @@ class CrmTeam(models.Model):
|
||||
team = default_team
|
||||
else:
|
||||
team = filtered_teams[:1]
|
||||
|
||||
# 2- any of my teams
|
||||
if not team:
|
||||
if default_team and default_team in teams:
|
||||
|
||||
Reference in New Issue
Block a user