diff --git a/addons/digest/tests/test_digest.py b/addons/digest/tests/test_digest.py index da1c8f7c8bf..827b091be65 100644 --- a/addons/digest/tests/test_digest.py +++ b/addons/digest/tests/test_digest.py @@ -17,7 +17,6 @@ class TestDigest(TestDigestCommon): @classmethod def setUpClass(cls): super(TestDigest, cls).setUpClass() - cls._activate_multi_company() # clean messages cls.env['mail.message'].search([ diff --git a/addons/mail/tests/common.py b/addons/mail/tests/common.py index f54008ad406..2692497a85e 100644 --- a/addons/mail/tests/common.py +++ b/addons/mail/tests/common.py @@ -1094,6 +1094,9 @@ class MailCommon(common.TransactionCase, MailCase): cls.user_root = cls.env.ref('base.user_root') cls.partner_root = cls.user_root.partner_id + # setup MC environment + cls._activate_multi_company() + # give default values for all email aliases and domain cls._init_mail_gateway() cls._init_mail_servers() @@ -1163,6 +1166,9 @@ class MailCommon(common.TransactionCase, MailCase): 'email': 'company_2@test.example.com', 'name': 'Company 2', }) + cls.company_3 = cls.env['res.company'].create({ + 'name': 'ELIT', + }) cls.user_admin.write({'company_ids': [(4, cls.company_2.id)]}) # employee specific to second company diff --git a/addons/mail/tests/discuss/test_discuss_channel.py b/addons/mail/tests/discuss/test_discuss_channel.py index c35e075a650..a609d992b0d 100644 --- a/addons/mail/tests/discuss/test_discuss_channel.py +++ b/addons/mail/tests/discuss/test_discuss_channel.py @@ -550,7 +550,6 @@ class TestChannelInternals(MailCommon): self.assertEqual(self.user_employee.with_user(self.user_employee)._init_messaging()['starred_counter'], 1) def test_multi_company_chat(self): - self._activate_multi_company() self.assertEqual(self.env.user.company_id, self.company_admin) with self.with_user('employee'): diff --git a/addons/mail/tests/test_res_partner.py b/addons/mail/tests/test_res_partner.py index d2adfacc70a..04346bb136d 100644 --- a/addons/mail/tests/test_res_partner.py +++ b/addons/mail/tests/test_res_partner.py @@ -19,7 +19,6 @@ class TestPartner(MailCommon): @classmethod def setUpClass(cls): super().setUpClass() - cls._activate_multi_company() cls.samples = [ ('"Raoul Grosbedon" ', 'Raoul Grosbedon', 'raoul@chirurgiens-dentistes.fr'), @@ -34,7 +33,6 @@ class TestPartner(MailCommon): # multi email ('"Multi Email" , multi.email.2@example.com', 'Multi Email', 'multi.email@example.com') ] - @contextmanager def mockPartnerCalls(self): _original_create = Partner.create diff --git a/addons/mail_group/tests/common.py b/addons/mail_group/tests/common.py index 03e2c64a478..82e57a2d158 100644 --- a/addons/mail_group/tests/common.py +++ b/addons/mail_group/tests/common.py @@ -55,8 +55,6 @@ class TestMailListCommon(MailCommon): }) cls.test_group_valid_members = cls.test_group_member_1 + cls.test_group_member_2 + cls.test_group_member_4_emp - cls._init_mail_gateway() - # Create some messages cls.test_group_msg_1_pending = cls.env['mail.group.message'].create({ 'subject': 'Test message pending', diff --git a/addons/portal/tests/test_portal_wizard.py b/addons/portal/tests/test_portal_wizard.py index f759bc5c841..e8c3f139d4c 100644 --- a/addons/portal/tests/test_portal_wizard.py +++ b/addons/portal/tests/test_portal_wizard.py @@ -158,8 +158,8 @@ class TestPortalWizard(MailCommon): portal_user.action_revoke_access() def test_portal_wizard_multi_company(self): - company_1 = self.env['res.company'].search([], limit=1) - company_2 = self.env['res.company'].create({'name': 'Company 2'}) + company_1 = self.company_admin + company_2 = self.company_2 partner_company_2 = self.env['res.partner'].with_company(company_2).create({ 'name': 'Testing Partner', diff --git a/addons/test_crm_full/tests/common.py b/addons/test_crm_full/tests/common.py index bce1f749eb8..60e0348042b 100644 --- a/addons/test_crm_full/tests/common.py +++ b/addons/test_crm_full/tests/common.py @@ -13,7 +13,6 @@ class TestCrmFullCommon(TestCrmCommon, MockIAPReveal, MockVisitor): @classmethod def setUpClass(cls): super(TestCrmFullCommon, cls).setUpClass() - cls._init_mail_gateway() cls._activate_multi_company() # Context data: dates diff --git a/addons/test_event_full/tests/common.py b/addons/test_event_full/tests/common.py index d3bf3aa5eac..b79b16b574e 100644 --- a/addons/test_event_full/tests/common.py +++ b/addons/test_event_full/tests/common.py @@ -15,7 +15,6 @@ class TestEventFullCommon(EventCrmCase, TestSalesCommon, MockVisitor): @classmethod def setUpClass(cls): super(TestEventFullCommon, cls).setUpClass() - cls._init_mail_gateway() # Context data: dates # ------------------------------------------------------------ diff --git a/addons/test_mail/tests/test_mail_alias.py b/addons/test_mail/tests/test_mail_alias.py index 5a2ea3e1522..d13fa75c04c 100644 --- a/addons/test_mail/tests/test_mail_alias.py +++ b/addons/test_mail/tests/test_mail_alias.py @@ -17,7 +17,6 @@ class TestMailAliasCommon(MailCommon): @classmethod def setUpClass(cls): super().setUpClass() - cls._activate_multi_company() cls.test_alias_mc = cls.env['mail.alias'].create({ 'alias_model_id': cls.env['ir.model']._get('mail.test.container.mc').id, diff --git a/addons/test_mail/tests/test_mail_gateway.py b/addons/test_mail/tests/test_mail_gateway.py index 4a38a8e9dcd..e3206f9e78d 100644 --- a/addons/test_mail/tests/test_mail_gateway.py +++ b/addons/test_mail/tests/test_mail_gateway.py @@ -152,7 +152,6 @@ class TestMailgateway(MailCommon): @classmethod def setUpClass(cls): super(TestMailgateway, cls).setUpClass() - cls._activate_multi_company() cls.mail_test_gateway_model = cls.env['ir.model']._get('mail.test.gateway') cls.email_from = '"Sylvie Lelitre" ' diff --git a/addons/test_mail/tests/test_mail_multicompany.py b/addons/test_mail/tests/test_mail_multicompany.py index d22563743fe..78819c2658b 100644 --- a/addons/test_mail/tests/test_mail_multicompany.py +++ b/addons/test_mail/tests/test_mail_multicompany.py @@ -21,7 +21,6 @@ class TestMailMCCommon(MailCommon, TestRecipients): @classmethod def setUpClass(cls): super().setUpClass() - cls._activate_multi_company() cls.test_model = cls.env['ir.model']._get('mail.test.gateway') cls.email_from = '"Sylvie Lelitre" ' @@ -37,7 +36,6 @@ class TestMailMCCommon(MailCommon, TestRecipients): 'company_id': cls.user_employee_c2.company_id.id}, ]) - cls.company_3 = cls.env['res.company'].create({'name': 'ELIT'}) cls.partner_1 = cls.env['res.partner'].with_context(cls._test_context).create({ 'name': 'Valid Lelitre', 'email': 'valid.lelitre@agrolait.com', @@ -438,11 +436,6 @@ class TestMultiCompanySetup(TestMailMCCommon): @tagged('-at_install', 'post_install', 'multi_company') class TestMultiCompanyRedirect(MailCommon, HttpCase): - @classmethod - def setUpClass(cls): - super(TestMultiCompanyRedirect, cls).setUpClass() - cls._activate_multi_company() - def test_redirect_to_records(self): """ Test mail/view redirection in MC environment, notably cids being added in redirect if user has access to the record. """ diff --git a/addons/test_mail/tests/test_message_post.py b/addons/test_mail/tests/test_message_post.py index 13d77c20ddf..f427839ab9e 100644 --- a/addons/test_mail/tests/test_message_post.py +++ b/addons/test_mail/tests/test_message_post.py @@ -1632,7 +1632,6 @@ class TestMessagePostLang(MailCommon, TestRecipients): 'groups_id': [(4, cls.env.ref('base.group_partner_manager').id)], }) - cls._activate_multi_company() cls._activate_multi_lang(test_record=cls.test_records[0], test_template=cls.test_template) cls.partner_2.write({'lang': 'es_ES'}) diff --git a/addons/test_mail/tests/test_message_track.py b/addons/test_mail/tests/test_message_track.py index 152fd91a52c..1a19bdbc27d 100644 --- a/addons/test_mail/tests/test_message_track.py +++ b/addons/test_mail/tests/test_message_track.py @@ -423,8 +423,6 @@ class TestTrackingMonetary(MailCommon): def setUp(self): super(TestTrackingMonetary, self).setUp() - self._activate_multi_company() - record = self.env['mail.test.track.monetary'].with_user(self.user_employee).with_context(self._test_context).create({ 'company_id': self.user_employee.company_id.id, })