@@ -30,7 +30,9 @@ def setUpClass(cls):
3030 cls .group_no_one_id = cls .env .ref ("base.group_no_one" )
3131 vals = {
3232 "name" : "ROLE_1" ,
33- "implied_ids" : [(6 , 0 , [cls .group_user_id .id , cls .group_no_one_id .id ])],
33+ "implied_ids" : [
34+ fields .Command .set ([cls .group_user_id .id , cls .group_no_one_id .id ])
35+ ],
3436 }
3537 cls .role1_id = cls .role_model .create (vals )
3638
@@ -42,14 +44,12 @@ def setUpClass(cls):
4244 vals = {
4345 "name" : "ROLE_2" ,
4446 "implied_ids" : [
45- (
46- 6 ,
47- 0 ,
47+ fields .Command .set (
4848 [
4949 cls .group_user_id .id ,
5050 cls .group_multi_currency_id .id ,
5151 cls .group_settings_id .id ,
52- ],
52+ ]
5353 )
5454 ],
5555 }
@@ -60,36 +60,44 @@ def setUpClass(cls):
6060 {
6161 "name" : "User 2" ,
6262 "company_id" : cls .company1 .id ,
63- "company_ids" : [(6 , 0 , [cls .company1 .id , cls .company2 .id ])],
64- "group_ids" : [(6 , 0 , cls .env .ref ("base.group_erp_manager" ).ids )],
63+ "company_ids" : [fields .Command .set ([cls .company1 .id , cls .company2 .id ])],
64+ "group_ids" : [
65+ fields .Command .set (cls .env .ref ("base.group_erp_manager" ).ids )
66+ ],
6567 "login" : "multicompany_user_1" ,
6668 }
6769 )
6870 cls .multicompany_user_2 = cls .user_model .create (
6971 {
7072 "name" : "User 2" ,
7173 "company_id" : cls .company2 .id ,
72- "company_ids" : [( 6 , 0 , [cls .company2 .id ])],
73- "group_ids" : [( 6 , 0 , cls .env .ref ("base.group_user" ).ids )],
74+ "company_ids" : [fields . Command . set ( [cls .company2 .id ])],
75+ "group_ids" : [fields . Command . set ( cls .env .ref ("base.group_user" ).ids )],
7476 "login" : "multicompany_user_2" ,
7577 }
7678 )
7779 cls .multicompany_role = cls .role_model .create (
7880 {
7981 "name" : "MULTICOMPANY_ROLE" ,
80- "implied_ids" : [(6 , 0 , [cls .group_user_id .id ])],
81- "line_ids" : [(0 , 0 , {"user_id" : cls .multicompany_user_2 .id })],
82+ "implied_ids" : [fields .Command .set ([cls .group_user_id .id ])],
83+ "line_ids" : [
84+ fields .Command .create ({"user_id" : cls .multicompany_user_2 .id })
85+ ],
8286 }
8387 )
8488
8589 def test_role_1 (self ):
86- self .user_id .write ({"role_line_ids" : [(0 , 0 , {"role_id" : self .role1_id .id })]})
90+ self .user_id .write (
91+ {"role_line_ids" : [fields .Command .create ({"role_id" : self .role1_id .id })]}
92+ )
8793 user_group_ids = sorted ({group .id for group in self .user_id .group_ids })
8894 role_group_ids = sorted (set (self .role1_id .all_implied_ids .ids ))
8995 self .assertEqual (user_group_ids , role_group_ids )
9096
9197 def test_role_2 (self ):
92- self .user_id .write ({"role_line_ids" : [(0 , 0 , {"role_id" : self .role2_id .id })]})
98+ self .user_id .write (
99+ {"role_line_ids" : [fields .Command .create ({"role_id" : self .role2_id .id })]}
100+ )
93101 user_group_ids = sorted ({group .id for group in self .user_id .group_ids })
94102 role_group_ids = sorted (set (self .role2_id .all_implied_ids .ids ))
95103 self .assertEqual (user_group_ids , role_group_ids )
@@ -98,8 +106,8 @@ def test_role_1_2(self):
98106 self .user_id .write (
99107 {
100108 "role_line_ids" : [
101- ( 0 , 0 , {"role_id" : self .role1_id .id }),
102- ( 0 , 0 , {"role_id" : self .role2_id .id }),
109+ fields . Command . create ( {"role_id" : self .role1_id .id }),
110+ fields . Command . create ( {"role_id" : self .role2_id .id }),
103111 ]
104112 }
105113 )
@@ -118,9 +126,13 @@ def test_role_1_2_with_dates(self):
118126 {
119127 "role_line_ids" : [
120128 # Role 1 should be enabled
121- (0 , 0 , {"role_id" : self .role1_id .id , "date_from" : today_str }),
129+ fields .Command .create (
130+ {"role_id" : self .role1_id .id , "date_from" : today_str }
131+ ),
122132 # Role 2 should be disabled
123- (0 , 0 , {"role_id" : self .role2_id .id , "date_to" : yesterday_str }),
133+ fields .Command .create (
134+ {"role_id" : self .role2_id .id , "date_to" : yesterday_str }
135+ ),
124136 ]
125137 }
126138 )
@@ -137,8 +149,8 @@ def test_role_unlink(self):
137149 self .user_id .write (
138150 {
139151 "role_line_ids" : [
140- ( 0 , 0 , {"role_id" : self .role1_id .id }),
141- ( 0 , 0 , {"role_id" : self .role2_id .id }),
152+ fields . Command . create ( {"role_id" : self .role1_id .id }),
153+ fields . Command . create ( {"role_id" : self .role2_id .id }),
142154 ]
143155 }
144156 )
@@ -165,8 +177,8 @@ def test_role_line_unlink(self):
165177 self .user_id .write (
166178 {
167179 "role_line_ids" : [
168- ( 0 , 0 , {"role_id" : self .role1_id .id }),
169- ( 0 , 0 , {"role_id" : self .role2_id .id }),
180+ fields . Command . create ( {"role_id" : self .role1_id .id }),
181+ fields . Command . create ( {"role_id" : self .role2_id .id }),
170182 ]
171183 }
172184 )
@@ -192,8 +204,8 @@ def test_default_user_roles(self):
192204 self .default_user .write (
193205 {
194206 "role_line_ids" : [
195- ( 0 , 0 , {"role_id" : self .role1_id .id }),
196- ( 0 , 0 , {"role_id" : self .role2_id .id }),
207+ fields . Command . create ( {"role_id" : self .role1_id .id }),
208+ fields . Command . create ( {"role_id" : self .role2_id .id }),
197209 ]
198210 }
199211 )
@@ -214,7 +226,7 @@ def test_role_multicompany(self):
214226 role .with_context (allowed_company_ids = self .company1 .ids ).read ()
215227 # Downgrade multicompany user 1 to common user
216228 self .multicompany_user_1 .write (
217- {"group_ids" : [( 6 , 0 , self .env .ref ("base.group_user" ).ids )]}
229+ {"group_ids" : [fields . Command . set ( self .env .ref ("base.group_user" ).ids )]}
218230 )
219231 # Check that the user cannot read multicompany data again since it lost
220232 # its admin privileges
@@ -245,7 +257,9 @@ def test_create_role_from_user(self):
245257
246258 def test_show_alert_computation (self ):
247259 """Test the computation of the `show_alert` field."""
248- self .user_id .write ({"role_line_ids" : [(0 , 0 , {"role_id" : self .role1_id .id })]})
260+ self .user_id .write (
261+ {"role_line_ids" : [fields .Command .create ({"role_id" : self .role1_id .id })]}
262+ )
249263 self .assertTrue (self .user_id .show_alert )
250264
251265 # disable role
0 commit comments