From f2491fe4f0266efd56313f50b3e0ecde6ce4913c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesu=CC=81s=20Alan=20Ramos=20Rodri=CC=81guez?= Date: Wed, 26 Jul 2023 18:17:39 -0600 Subject: [PATCH] [MIG] sales_team_operating_unit: Migration to 16.0 --- sales_team_operating_unit/__manifest__.py | 2 +- .../tests/test_crm_team_operating_unit.py | 43 ++++++++++--------- .../views/crm_team_view.xml | 5 +-- 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/sales_team_operating_unit/__manifest__.py b/sales_team_operating_unit/__manifest__.py index 961bb0a3bb..6950267ee7 100644 --- a/sales_team_operating_unit/__manifest__.py +++ b/sales_team_operating_unit/__manifest__.py @@ -4,7 +4,7 @@ # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). { "name": "Sales Team Operating Unit", - "version": "15.0.1.0.0", + "version": "16.0.1.0.0", "author": "ForgeFlow, SerpentCS, Odoo Community Association (OCA)", "license": "LGPL-3", "website": "https://github.com/OCA/operating-unit", diff --git a/sales_team_operating_unit/tests/test_crm_team_operating_unit.py b/sales_team_operating_unit/tests/test_crm_team_operating_unit.py index cd44ab1dff..f12b683805 100644 --- a/sales_team_operating_unit/tests/test_crm_team_operating_unit.py +++ b/sales_team_operating_unit/tests/test_crm_team_operating_unit.py @@ -6,38 +6,40 @@ class TestSaleTeamOperatingUnit(common.TransactionCase): - def setUp(self): - super(TestSaleTeamOperatingUnit, self).setUp() - self.res_users_model = self.env["res.users"].with_context( + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.res_users_model = cls.env["res.users"].with_context( tracking_disable=True, no_reset_password=True ) - self.crm_team_model = self.env["crm.team"] + cls.crm_team_model = cls.env["crm.team"] # Groups - self.grp_sale_mngr = self.env.ref("sales_team.group_sale_manager") - self.grp_user = self.env.ref("operating_unit.group_multi_operating_unit") + cls.grp_sale_mngr = cls.env.ref("sales_team.group_sale_manager") + cls.grp_user = cls.env.ref("operating_unit.group_multi_operating_unit") # Company - self.company = self.env.ref("base.main_company") + cls.company = cls.env.ref("base.main_company") # Main Operating Unit - self.ou1 = self.env.ref("operating_unit.main_operating_unit") + cls.ou1 = cls.env.ref("operating_unit.main_operating_unit") # B2C Operating Unit - self.b2c = self.env.ref("operating_unit.b2c_operating_unit") + cls.b2c = cls.env.ref("operating_unit.b2c_operating_unit") # Create User 1 with Main OU - self.user1 = self._create_user( - "user_1", [self.grp_sale_mngr, self.grp_user], self.company, [self.ou1] + cls.user1 = cls._create_user( + "user_1", [cls.grp_sale_mngr, cls.grp_user], cls.company, [cls.ou1] ) # Create User 2 with B2C OU - self.user2 = self._create_user( - "user_2", [self.grp_sale_mngr, self.grp_user], self.company, [self.b2c] + cls.user2 = cls._create_user( + "user_2", [cls.grp_sale_mngr, cls.grp_user], cls.company, [cls.b2c] ) # Create CRM teams - self.team1 = self._create_crm_team(self.user1.id, self.ou1) - self.team2 = self._create_crm_team(self.user2.id, self.b2c) + cls.team1 = cls._create_crm_team(cls.user1.id, cls.ou1) + cls.team2 = cls._create_crm_team(cls.user2.id, cls.b2c) - def _create_user(self, login, groups, company, operating_units, context=None): + @classmethod + def _create_user(cls, login, groups, company, operating_units, context=None): """Create a user.""" group_ids = [group.id for group in groups] - user = self.res_users_model.create( + user = cls.res_users_model.create( { "name": "Test User", "login": login, @@ -51,13 +53,14 @@ def _create_user(self, login, groups, company, operating_units, context=None): ) return user - def _create_crm_team(self, uid, operating_unit): + @classmethod + def _create_crm_team(cls, uid, operating_unit): """Create a Sales Team.""" - crm = self.crm_team_model.with_user(uid).create( + crm = cls.crm_team_model.with_user(uid).create( { "name": "CRM team", "operating_unit_id": operating_unit.id, - "company_id": self.company.id, + "company_id": cls.company.id, } ) return crm diff --git a/sales_team_operating_unit/views/crm_team_view.xml b/sales_team_operating_unit/views/crm_team_view.xml index 9e0818b8f1..0cfe2086e9 100644 --- a/sales_team_operating_unit/views/crm_team_view.xml +++ b/sales_team_operating_unit/views/crm_team_view.xml @@ -21,12 +21,11 @@ crm.team - +