@@ -10,9 +10,15 @@ def setUpClass(cls):
1010 super ().setUpClass ()
1111 cls .customer_loc = cls .env .ref ("stock.stock_location_customers" )
1212 cls .output_loc = cls .env .ref ("stock.stock_location_output" )
13- cls .product = cls .env .ref ("product.product_product_16" ).copy ()
14- cls .product .write ({"tracking" : "lot" })
1513 cls .warehouse = cls .env .ref ("stock.warehouse0" )
14+ cls .product = cls .env ["product.product" ].create (
15+ {
16+ "name" : "Test Product" ,
17+ "type" : "consu" ,
18+ "is_storable" : True ,
19+ "tracking" : "lot" ,
20+ }
21+ )
1622 cls .warehouse .write ({"delivery_steps" : "pick_ship" })
1723 cls .stock_loc = cls .warehouse .lot_stock_id
1824
@@ -43,7 +49,6 @@ def _create_move_with_lot(self):
4349 "location_dest_id" : self .output_loc .id ,
4450 "product_uom_qty" : 1 ,
4551 "product_uom" : self .product .uom_id .id ,
46- "name" : "test" ,
4752 "procure_method" : "make_to_order" ,
4853 "warehouse_id" : self .warehouse .id ,
4954 "route_ids" : [(6 , 0 , self .warehouse .delivery_route_id .ids )],
@@ -70,7 +75,6 @@ def _create_move_dest(self):
7075 "product_uom" : self .product .uom_id .id ,
7176 "picking_type_id" : self .warehouse .out_type_id .id ,
7277 "location_dest_id" : self .output_loc .id ,
73- "name" : "test" ,
7478 "procure_method" : "make_to_order" ,
7579 "warehouse_id" : self .warehouse .id ,
7680 "route_ids" : [(6 , 0 , self .warehouse .delivery_route_id .ids )],
@@ -87,7 +91,6 @@ def test_00_move_restrict_lot_propagation(self):
8791 "location_dest_id" : self .output_loc .id ,
8892 "product_uom_qty" : 1 ,
8993 "product_uom" : self .product .uom_id .id ,
90- "name" : "test" ,
9194 "procure_method" : "make_to_order" ,
9295 "warehouse_id" : self .warehouse .id ,
9396 "route_ids" : [(6 , 0 , self .warehouse .delivery_route_id .ids )],
@@ -106,7 +109,6 @@ def test_01_move_split_and_copy(self):
106109 "location_dest_id" : self .output_loc .id ,
107110 "product_uom_qty" : 2 ,
108111 "product_uom" : self .product .uom_id .id ,
109- "name" : "test" ,
110112 "procure_method" : "make_to_stock" ,
111113 "warehouse_id" : self .warehouse .id ,
112114 "route_ids" : [(6 , 0 , self .warehouse .delivery_route_id .ids )],
@@ -150,7 +152,6 @@ def test_02_move_restrict_lot_reservation(self):
150152 "location_dest_id" : self .customer_loc .id ,
151153 "product_uom_qty" : 1 ,
152154 "product_uom" : self .product .uom_id .id ,
153- "name" : "test" ,
154155 "warehouse_id" : self .warehouse .id ,
155156 "restrict_lot_id" : self .lot .id ,
156157 }
@@ -196,12 +197,10 @@ def test_procurement_with_2_steps_output(self):
196197 self ._update_product_stock (25 , lot2 .id , location = location_2 )
197198
198199 # create a procurement with two lines of same product with different lots
199- procurement_group = self .env ["procurement.group" ].create (
200- {"name" : "My procurement" , "move_type" : "one" }
201- )
202- self .env ["procurement.group" ].run (
200+ reference = self .env ["stock.reference" ].create ({"name" : "My procurement" })
201+ self .env ["stock.rule" ].run (
203202 [
204- self .env ["procurement.group " ].Procurement (
203+ self .env ["stock.rule " ].Procurement (
205204 self .product ,
206205 15 ,
207206 self .product .uom_id ,
@@ -210,11 +209,12 @@ def test_procurement_with_2_steps_output(self):
210209 "an origin restrict on lot 1" ,
211210 self .env .company ,
212211 {
213- "group_id" : procurement_group ,
212+ "warehouse_id" : self .warehouse ,
213+ "reference_ids" : reference ,
214214 "restrict_lot_id" : self .lot .id ,
215215 },
216216 ),
217- self .env ["procurement.group " ].Procurement (
217+ self .env ["stock.rule " ].Procurement (
218218 self .product ,
219219 30 ,
220220 self .product .uom_id ,
@@ -223,7 +223,8 @@ def test_procurement_with_2_steps_output(self):
223223 "an origin restrict on lot 2" ,
224224 self .env .company ,
225225 {
226- "group_id" : procurement_group ,
226+ "warehouse_id" : self .warehouse ,
227+ "reference_ids" : reference ,
227228 "restrict_lot_id" : lot2 .id ,
228229 },
229230 ),
@@ -249,34 +250,28 @@ def assert_move_line_per_lot_and_location(
249250 concern_move_line .quantity_product_uom , expect_reserved_qty
250251 )
251252
252- pick = procurement_group .stock_move_ids .picking_id
253- self .assertEqual (len (pick ), 1 )
254- self .assertEqual (pick .picking_type_id .code , "internal" )
253+ pick = reference .move_ids .picking_id [0 ]
255254 self .assertEqual (pick .state , "assigned" )
256255 self .assertEqual (len (pick .move_ids ), 2 )
257- assert_move_qty_per_lot (pick .move_ids_without_package , self .lot , 15 )
258- assert_move_qty_per_lot (pick .move_ids_without_package , lot2 , 30 )
259- assert_move_line_per_lot_and_location (
260- pick .move_line_ids_without_package , self .lot , location_1 , 10
261- )
262- assert_move_line_per_lot_and_location (
263- pick .move_line_ids_without_package , self .lot , location_2 , 5
264- )
256+ assert_move_qty_per_lot (pick .move_ids , self .lot , 15 )
257+ assert_move_qty_per_lot (pick .move_ids , lot2 , 30 )
265258 assert_move_line_per_lot_and_location (
266- pick .move_line_ids_without_package , lot2 , location_1 , 5
259+ pick .move_line_ids , self . lot , location_1 , 10
267260 )
268261 assert_move_line_per_lot_and_location (
269- pick .move_line_ids_without_package , lot2 , location_2 , 25
262+ pick .move_line_ids , self . lot , location_2 , 5
270263 )
264+ assert_move_line_per_lot_and_location (pick .move_line_ids , lot2 , location_1 , 5 )
265+ assert_move_line_per_lot_and_location (pick .move_line_ids , lot2 , location_2 , 25 )
271266 pick .button_validate ()
272267 self .assertEqual (pick .state , "done" )
273268
274- delivery = procurement_group . stock_move_ids .picking_id - pick
269+ delivery = reference . move_ids .picking_id - pick
275270 self .assertEqual (delivery .picking_type_id .code , "outgoing" )
276271 self .assertEqual (delivery .state , "assigned" )
277272
278- assert_move_qty_per_lot (delivery .move_ids_without_package , self .lot , 15 )
279- assert_move_qty_per_lot (delivery .move_ids_without_package , lot2 , 30 )
273+ assert_move_qty_per_lot (delivery .move_ids , self .lot , 15 )
274+ assert_move_qty_per_lot (delivery .move_ids , lot2 , 30 )
280275
281276 def test_compute_quantites (self ):
282277 move = self .env ["stock.move" ].create (
@@ -286,7 +281,6 @@ def test_compute_quantites(self):
286281 "location_dest_id" : self .customer_loc .id ,
287282 "product_uom_qty" : 1 ,
288283 "product_uom" : self .product .uom_id .id ,
289- "name" : "test" ,
290284 "procure_method" : "make_to_stock" ,
291285 "warehouse_id" : self .warehouse .id ,
292286 "route_ids" : [(6 , 0 , self .warehouse .delivery_route_id .ids )],
@@ -333,7 +327,6 @@ def test_move_validation_inconsistent_lot(self):
333327 "location_dest_id" : self .customer_loc .id ,
334328 "product_uom_qty" : 1 ,
335329 "product_uom" : self .product .uom_id .id ,
336- "name" : "test" ,
337330 "warehouse_id" : self .warehouse .id ,
338331 "restrict_lot_id" : self .lot .id ,
339332 }
0 commit comments