summaryrefslogtreecommitdiff
path: root/addons/hr/tests/test_multi_company.py
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
commit3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch)
treea44932296ef4a9b71d5f010906253d8c53727726 /addons/hr/tests/test_multi_company.py
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
Diffstat (limited to 'addons/hr/tests/test_multi_company.py')
-rw-r--r--addons/hr/tests/test_multi_company.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/addons/hr/tests/test_multi_company.py b/addons/hr/tests/test_multi_company.py
new file mode 100644
index 00000000..10f9c4f8
--- /dev/null
+++ b/addons/hr/tests/test_multi_company.py
@@ -0,0 +1,36 @@
+# -*- 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_company(
+ self.company_1
+ )._render_qweb_pdf(res_ids=self.employees.ids)