19.0 vanilla

This commit is contained in:
Ernad Husremovic 2026-03-09 09:32:12 +01:00
parent 79f83631d5
commit 73afc09215
6267 changed files with 1534193 additions and 1130106 deletions

View file

@ -1,10 +1,14 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import exceptions
from odoo.tests import tagged, users
from odoo.addons.mail.tests.common import mail_new_test_user
from odoo.addons.sales_team.tests.common import SalesTeamCommon, TestSalesCommon, TestSalesMC
from odoo.addons.sales_team.tests.common import (
SalesTeamCommon,
TestSalesCommon,
TestSalesMC,
)
class TestDefaultTeam(TestSalesCommon):
@ -164,7 +168,7 @@ class TestMultiCompany(TestSalesMC):
team_c2.write({'member_ids': [(4, self.env.user.id)]})
self.assertEqual(team_c2.member_ids, self.env.user)
# cannot add someone from another company
# cannot add someone from another company (when user allowed only in c1 and team is in c2)
with self.assertRaises(exceptions.UserError):
team_c2.write({'member_ids': [(4, self.user_sales_salesman.id)]})
@ -174,10 +178,25 @@ class TestMultiCompany(TestSalesMC):
team_c2.write({'member_ids': [(4, self.user_sales_salesman.id)]})
self.assertEqual(team_c2.member_ids, self.user_sales_salesman)
# cannot change company as it breaks memberships mc check
# cannot change team company if its users aren't allowed in the new company
with self.assertRaises(exceptions.UserError):
team_c2.write({'company_id': self.company_2.id})
# a user allowed in multiple companies can be added to a team of any of these companies
team_c2.write({'member_ids': [(5, 0)]})
team_c2.write({'company_id': self.company_2.id})
c1, c2 = self.company_main, self.company_2
with self.with_user('admin'): # user_sales_manager can't create user
user_c1_c2 = mail_new_test_user(
self.env,
login=f"Test_user_default_to_c{c1.id}_allowed_c{'c'.join(map(str, [c1.id, c2.id]))}",
company_id=c1.id,
company_ids=[(4, company.id) for company in c1 + c2]
)
user_c1_c2 = user_c1_c2.with_env(self.env)
team_c2.write({'member_ids': [(4, user_c1_c2.id)]})
self.assertIn(user_c1_c2, team_c2.member_ids)
@users('user_sales_manager')
def test_team_memberships(self):
""" Test update of team member involving company check """