@@ -20,7 +20,7 @@ def setUpClass(cls):
2020
2121 cls .company1 = cls .env .ref ("base.main_company" )
2222 cls .company2 = cls .env ["res.company" ].create ({"name" : "company2" })
23- cls .default_user = cls .env .ref ("base.default_user " )
23+ cls .default_user = cls .env .ref ("base.template_portal_user_id " )
2424 cls .user_id = cls .user_model .create (
2525 {"name" : "USER TEST (ROLES)" , "login" : "user_test_roles" }
2626 )
@@ -61,7 +61,7 @@ def setUpClass(cls):
6161 "name" : "User 2" ,
6262 "company_id" : cls .company1 .id ,
6363 "company_ids" : [(6 , 0 , [cls .company1 .id , cls .company2 .id ])],
64- "groups_id " : [(6 , 0 , cls .env .ref ("base.group_erp_manager" ).ids )],
64+ "group_ids " : [(6 , 0 , cls .env .ref ("base.group_erp_manager" ).ids )],
6565 "login" : "multicompany_user_1" ,
6666 }
6767 )
@@ -70,7 +70,7 @@ def setUpClass(cls):
7070 "name" : "User 2" ,
7171 "company_id" : cls .company2 .id ,
7272 "company_ids" : [(6 , 0 , [cls .company2 .id ])],
73- "groups_id " : [(6 , 0 , cls .env .ref ("base.group_user" ).ids )],
73+ "group_ids " : [(6 , 0 , cls .env .ref ("base.group_user" ).ids )],
7474 "login" : "multicompany_user_2" ,
7575 }
7676 )
@@ -84,18 +84,14 @@ def setUpClass(cls):
8484
8585 def test_role_1 (self ):
8686 self .user_id .write ({"role_line_ids" : [(0 , 0 , {"role_id" : self .role1_id .id })]})
87- user_group_ids = sorted ({group .id for group in self .user_id .groups_id })
88- role_group_ids = self .role1_id .trans_implied_ids .ids
89- role_group_ids .append (self .role1_id .group_id .id )
90- role_group_ids = sorted (set (role_group_ids ))
87+ user_group_ids = sorted ({group .id for group in self .user_id .group_ids })
88+ role_group_ids = sorted (set (self .role1_id .all_implied_ids .ids ))
9189 self .assertEqual (user_group_ids , role_group_ids )
9290
9391 def test_role_2 (self ):
9492 self .user_id .write ({"role_line_ids" : [(0 , 0 , {"role_id" : self .role2_id .id })]})
95- user_group_ids = sorted ({group .id for group in self .user_id .groups_id })
96- role_group_ids = self .role2_id .trans_implied_ids .ids
97- role_group_ids .append (self .role2_id .group_id .id )
98- role_group_ids = sorted (set (role_group_ids ))
93+ user_group_ids = sorted ({group .id for group in self .user_id .group_ids })
94+ role_group_ids = sorted (set (self .role2_id .all_implied_ids .ids ))
9995 self .assertEqual (user_group_ids , role_group_ids )
10096
10197 def test_role_1_2 (self ):
@@ -107,11 +103,9 @@ def test_role_1_2(self):
107103 ]
108104 }
109105 )
110- user_group_ids = sorted ({group .id for group in self .user_id .groups_id })
111- role1_group_ids = self .role1_id .trans_implied_ids .ids
112- role1_group_ids .append (self .role1_id .group_id .id )
113- role2_group_ids = self .role2_id .trans_implied_ids .ids
114- role2_group_ids .append (self .role2_id .group_id .id )
106+ user_group_ids = sorted ({group .id for group in self .user_id .group_ids })
107+ role1_group_ids = self .role1_id .all_implied_ids .ids
108+ role2_group_ids = self .role2_id .all_implied_ids .ids
115109 role_group_ids = sorted (set (role1_group_ids + role2_group_ids ))
116110 self .assertEqual (user_group_ids , role_group_ids )
117111
@@ -130,16 +124,14 @@ def test_role_1_2_with_dates(self):
130124 ]
131125 }
132126 )
133- user_group_ids = sorted ({group .id for group in self .user_id .groups_id })
134- role1_group_ids = self .role1_id .trans_implied_ids .ids
135- role1_group_ids .append (self .role1_id .group_id .id )
136- role_group_ids = sorted (set (role1_group_ids ))
127+ user_group_ids = sorted ({group .id for group in self .user_id .group_ids })
128+ role_group_ids = sorted (set (self .role1_id .all_implied_ids .ids ))
137129 self .assertEqual (user_group_ids , role_group_ids )
138130
139131 def test_role_unlink (self ):
140132 # Get role1 and role2 groups
141- role1_groups = self .role1_id .trans_implied_ids | self . role1_id . group_id
142- role2_groups = self .role2_id .trans_implied_ids | self . role2_id . group_id
133+ role1_groups = self .role1_id .all_implied_ids
134+ role2_groups = self .role2_id .all_implied_ids
143135
144136 # Configure the user with role1 and role2
145137 self .user_id .write (
@@ -151,23 +143,23 @@ def test_role_unlink(self):
151143 }
152144 )
153145 # Check user has groups from role1 and role2
154- self .assertLessEqual (role1_groups , self .user_id .groups_id )
155- self .assertLessEqual (role2_groups , self .user_id .groups_id )
146+ self .assertLessEqual (role1_groups , self .user_id .group_ids )
147+ self .assertLessEqual (role2_groups , self .user_id .group_ids )
156148 # Remove role2
157149 self .role2_id .unlink ()
158150 # Check user has groups from only role1
159- self .assertLessEqual (role1_groups , self .user_id .groups_id )
160- self .assertFalse (role2_groups <= self .user_id .groups_id )
151+ self .assertLessEqual (role1_groups , self .user_id .group_ids )
152+ self .assertFalse (role2_groups <= self .user_id .group_ids )
161153 # Remove role1
162154 self .role1_id .unlink ()
163155 # Check user has no groups from role1 and role2
164- self .assertFalse (role1_groups <= self .user_id .groups_id )
165- self .assertFalse (role2_groups <= self .user_id .groups_id )
156+ self .assertFalse (role1_groups <= self .user_id .group_ids )
157+ self .assertFalse (role2_groups <= self .user_id .group_ids )
166158
167159 def test_role_line_unlink (self ):
168160 # Get role1 and role2 groups
169- role1_groups = self .role1_id .trans_implied_ids | self . role1_id . group_id
170- role2_groups = self .role2_id .trans_implied_ids | self . role2_id . group_id
161+ role1_groups = self .role1_id .all_implied_ids
162+ role2_groups = self .role2_id .all_implied_ids
171163
172164 # Configure the user with role1 and role2
173165 self .user_id .write (
@@ -179,22 +171,22 @@ def test_role_line_unlink(self):
179171 }
180172 )
181173 # Check user has groups from role1 and role2
182- self .assertLessEqual (role1_groups , self .user_id .groups_id )
183- self .assertLessEqual (role2_groups , self .user_id .groups_id )
174+ self .assertLessEqual (role1_groups , self .user_id .group_ids )
175+ self .assertLessEqual (role2_groups , self .user_id .group_ids )
184176 # Remove role2 from the user
185177 self .user_id .role_line_ids .filtered (
186178 lambda rl : rl .role_id .id == self .role2_id .id
187179 ).unlink ()
188180 # Check user has groups from only role1
189- self .assertLessEqual (role1_groups , self .user_id .groups_id )
190- self .assertFalse (role2_groups <= self .user_id .groups_id )
181+ self .assertLessEqual (role1_groups , self .user_id .group_ids )
182+ self .assertFalse (role2_groups <= self .user_id .group_ids )
191183 # Remove role1 from the user
192184 self .user_id .role_line_ids .filtered (
193185 lambda rl : rl .role_id .id == self .role1_id .id
194186 ).unlink ()
195187 # Check user has no groups from role1 and role2
196- self .assertFalse (role1_groups <= self .user_id .groups_id )
197- self .assertFalse (role2_groups <= self .user_id .groups_id )
188+ self .assertFalse (role1_groups <= self .user_id .group_ids )
189+ self .assertFalse (role2_groups <= self .user_id .group_ids )
198190
199191 def test_default_user_roles (self ):
200192 self .default_user .write (
@@ -222,7 +214,7 @@ def test_role_multicompany(self):
222214 role .with_context (allowed_company_ids = self .company1 .ids ).read ()
223215 # Downgrade multicompany user 1 to common user
224216 self .multicompany_user_1 .write (
225- {"groups_id " : [(6 , 0 , self .env .ref ("base.group_user" ).ids )]}
217+ {"group_ids " : [(6 , 0 , self .env .ref ("base.group_user" ).ids )]}
226218 )
227219 # Check that the user cannot read multicompany data again since it lost
228220 # its admin privileges
@@ -247,8 +239,8 @@ def test_create_role_from_user(self):
247239 # Check that the role has the same groups as the user
248240 role_id = result ["res_id" ]
249241 role = self .role_model .browse ([role_id ])
250- user_group_ids = sorted (set (self .user_id .groups_id .ids ))
251- role_group_ids = sorted (set (role .trans_implied_ids .ids ))
242+ user_group_ids = sorted (set (self .user_id .group_ids .ids ))
243+ role_group_ids = sorted (set (role .implied_ids .ids ))
252244 self .assertEqual (user_group_ids , role_group_ids )
253245
254246 def test_show_alert_computation (self ):
@@ -261,7 +253,7 @@ def test_show_alert_computation(self):
261253 self .assertFalse (self .user_id .show_alert )
262254
263255 def test_group_groups_into_role (self ):
264- user_group_ids = self .user_id .groups_id .ids
256+ user_group_ids = self .user_id .group_ids .ids
265257 # Check that there is not a role with name: Test Role
266258 self .assertFalse (self .role_model .search ([("name" , "=" , "Test Role" )]))
267259 # Call create_role function to group groups into a role
0 commit comments