The Common partner contact setting is removed from general settings because its behavior wasn't really clean from a technical point of view (disabling the rule on partner access) and wouldn't work as well with new multi-company logic. The default logic of sharing partner will be kept, but when someone wants to limit partner sharing, he will do so partner by partner, by setting the company_id. Also, the default company_id on a partner will be blank so default partner will be a sharable by multi-company. when the partner is created at the time of user creation then the partner's company will be the same as user's company.and when the partner is created at the time of company creation(partner related to company) then the company of partner will be newly created company. task-2024446 Closes: #35266
37 lines
1.6 KiB
Python
37 lines
1.6 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo.tests import Form
|
|
from odoo.addons.hr.tests.common import TestHrCommon
|
|
from odoo.addons.base.models.qweb import QWebException
|
|
|
|
|
|
class TestMultiCompany(TestHrCommon):
|
|
|
|
def setUp(self):
|
|
super().setUp()
|
|
self.company_1 = self.env['res.company'].create({'name': 'Opoo'})
|
|
self.company_2 = self.env['res.company'].create({'name': 'Otoo'})
|
|
self.employees = self.env['hr.employee'].create([
|
|
{'name': 'Bidule', 'company_id': self.company_1.id},
|
|
{'name': 'Machin', 'company_id': self.company_2.id},
|
|
])
|
|
self.res_users_hr_officer.company_ids = [
|
|
(4, self.company_1.id),
|
|
(4, self.company_2.id),
|
|
]
|
|
self.res_users_hr_officer.company_id = self.company_1.id
|
|
|
|
def test_multi_company_report(self):
|
|
content, content_type = self.env.ref('hr.hr_employee_print_badge').with_user(self.res_users_hr_officer).with_context(
|
|
allowed_company_ids=[self.company_1.id, self.company_2.id]
|
|
).render_qweb_pdf(res_ids=self.employees.ids)
|
|
self.assertIn(b'Bidule', content)
|
|
self.assertIn(b'Machin', content)
|
|
|
|
def test_single_company_report(self):
|
|
with self.assertRaises(QWebException): # CacheMiss followed by AccessError
|
|
content, content_type = self.env.ref('hr.hr_employee_print_badge').with_user(self.res_users_hr_officer).with_context(
|
|
allowed_company_ids=[self.company_1.id]
|
|
).render_qweb_pdf(res_ids=self.employees.ids)
|