[FIX] sales_team: ensure determinism when finding sales team
Current sales team ordering is based on sequence. However several sales teams with same sequence may exist. This leads to a not deterministic behavior as we are unsure how database will choose the ordering. This is fixed with this commit: when having teams with same sequence we take the newest one first. Task-2852947 X-original-commit: 34da99f6bec92553febfae7bc9c80ccebb38f70f Part-of: odoo/odoo#94045
This commit is contained in:
committed by
mafo-odoo
parent
741a7e376e
commit
deb66c90d8
@@ -17,7 +17,7 @@ class CrmTeam(models.Model):
|
||||
_name = "crm.team"
|
||||
_inherit = ['mail.thread']
|
||||
_description = "Sales Team"
|
||||
_order = "sequence"
|
||||
_order = "sequence ASC, create_date DESC, id DESC"
|
||||
_check_company_auto = True
|
||||
|
||||
def _get_default_team_id(self, user_id=None, domain=None):
|
||||
@@ -52,7 +52,7 @@ class CrmTeam(models.Model):
|
||||
team = self.env['crm.team']
|
||||
teams = self.env['crm.team'].search([
|
||||
('company_id', 'in', valid_cids),
|
||||
'|', ('user_id', '=', user.id), ('member_ids', 'in', [user.id]),
|
||||
'|', ('user_id', '=', user.id), ('member_ids', 'in', [user.id])
|
||||
])
|
||||
if teams and domain:
|
||||
team = teams.filtered_domain(domain)[:1]
|
||||
|
||||
Reference in New Issue
Block a user