44# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
55
66from odoo .exceptions import ValidationError
7- from odoo .models import Command
7+ from odoo .fields import Command , Domain
88
99from odoo .addons .operating_unit .tests .common import OperatingUnitCommon
1010
@@ -27,7 +27,7 @@ def setUpClass(cls):
2727 # Customer
2828 cls .customer = cls .env .ref ("base.res_partner_2" )
2929 # Price list
30- cls .pricelist = cls .env ["product.pricelist" ].search ([] , limit = 1 )
30+ cls .pricelist = cls .env ["product.pricelist" ].search (Domain . TRUE , limit = 1 )
3131 # Products
3232 cls .product1 = cls .env .ref ("product.product_product_2" )
3333 cls .product1 .write ({"invoice_policy" : "order" })
@@ -138,7 +138,12 @@ def test_security(self):
138138 # User 2 is only assigned to Operating Unit B2C, and cannot
139139 # Access Sales order from Main Operating Unit.
140140 sale = self .sale_model .with_user (self .user2 .id ).search (
141- [("id" , "=" , self .sale1 .id ), ("operating_unit_id" , "=" , self .ou1 .id )]
141+ Domain .AND (
142+ [
143+ Domain ("id" , "=" , self .sale1 .id ),
144+ Domain ("operating_unit_id" , "=" , self .ou1 .id ),
145+ ]
146+ )
142147 )
143148 self .assertEqual (
144149 sale .ids , [], f"User 2 should not have access to OU { self .ou1 .name } "
@@ -149,7 +154,12 @@ def test_security(self):
149154 b2c_invoice_id = self ._confirm_sale (self .sale2 )
150155 # Checks that invoice has OU b2c
151156 b2c = self .acc_move_model .with_user (self .user2 .id ).search (
152- [("id" , "=" , b2c_invoice_id ), ("operating_unit_id" , "=" , self .b2c .id )]
157+ Domain .AND (
158+ [
159+ Domain ("id" , "=" , b2c_invoice_id ),
160+ Domain ("operating_unit_id" , "=" , self .b2c .id ),
161+ ]
162+ )
153163 )
154164 self .assertNotEqual (b2c .ids , [], "Invoice should have b2c OU" )
155165
@@ -158,14 +168,24 @@ def test_security_2(self):
158168 # User 2 is only assigned to Operating Unit B2C, and cannot
159169 # Access Sales order from Main Operating Unit.
160170 sale = self .sale_model .with_user (self .user2 .id ).search (
161- [("id" , "=" , self .sale1 .id ), ("operating_unit_id" , "=" , self .ou1 .id )]
171+ Domain .AND (
172+ [
173+ Domain ("id" , "=" , self .sale1 .id ),
174+ Domain ("operating_unit_id" , "=" , self .ou1 .id ),
175+ ]
176+ )
162177 )
163178 self .assertEqual (
164179 sale .ids , [], f"User 2 should not have access to OU { self .ou1 .name } "
165180 )
166181
167182 sale = self .sale_model .with_user (self .user2 .id ).search (
168- [("id" , "=" , self .sale2 .id ), ("operating_unit_id" , "=" , self .b2c .id )]
183+ Domain .AND (
184+ [
185+ Domain ("id" , "=" , self .sale2 .id ),
186+ Domain ("operating_unit_id" , "=" , self .b2c .id ),
187+ ]
188+ )
169189 )
170190
171191 self .assertEqual (
0 commit comments