11# Copyright 2017 ACSONE SA/NV
22# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
33
4+ import odoo
45from odoo .exceptions import UserError
5- from odoo .tests import Form , common
6+ from odoo .tests import Form
67
8+ from odoo .addons .base .tests .common import BaseCommon
79
8- @common .tagged ("-at_install" , "post_install" )
9- class TestStockPicking (common .TransactionCase ):
10+
11+ @odoo .tests .tagged ("-at_install" , "post_install" )
12+ class TestStockPicking (BaseCommon ):
1013 @classmethod
1114 def setUpClass (cls ):
1215 super ().setUpClass ()
@@ -250,11 +253,11 @@ def test_action_pack_operation_auto_fill(self):
250253 # The expected result is only operations with product_id set and
251254 # the product_id.tracking == none, have a qty_done set.
252255 self .picking .action_pack_operation_auto_fill ()
253- self .assertFalse (product_8_op .qty_done )
254- self .assertEqual (product_9_op .reserved_uom_qty , product_9_op . qty_done )
255- self .assertFalse (product_10_op .qty_done )
256- self .assertEqual (product_11_op .reserved_uom_qty , product_11_op . qty_done )
257- self .assertEqual (product_12_op .reserved_uom_qty , product_12_op . qty_done )
256+ self .assertFalse (product_8_op .picked )
257+ self .assertTrue (product_9_op .picked )
258+ self .assertFalse (product_10_op .picked )
259+ self .assertTrue (product_11_op .picked )
260+ self .assertTrue (product_12_op .picked )
258261
259262 def test_action_auto_transfer (self ):
260263 # set tracking on the products
@@ -306,8 +309,8 @@ def test_action_auto_transfer(self):
306309
307310 # Try to fill all the operation automatically.
308311 # The expected result is only opertions with product_id set and
309- self .assertTrue (product_8_op .qty_done )
310- self .assertTrue (product_9_op .qty_done )
312+ self .assertFalse (product_8_op .picked )
313+ self .assertFalse (product_9_op .picked )
311314
312315 def test_action_auto_transfer_avoid_assign_lots (self ):
313316 # set tracking on the products
@@ -379,8 +382,8 @@ def test_action_auto_transfer_avoid_assign_lots(self):
379382
380383 # Try to fill all the operation automatically.
381384 # The expected result is only opertions with product_id set and
382- self .assertFalse (product_8_op .qty_done )
383- self .assertTrue (product_9_op .qty_done )
385+ self .assertFalse (product_8_op .picked )
386+ self .assertTrue (product_9_op .picked )
384387
385388 def test_action_assign_replenish_stock (self ):
386389 # Covered case:
@@ -414,10 +417,10 @@ def test_action_assign_replenish_stock(self):
414417 self .assertEqual (self .picking .state , "assigned" )
415418 self .assertEqual (len (self .picking .move_line_ids ), 1 )
416419 # Try to fill all the operation automatically.
417- self .assertEqual (self .picking .move_line_ids .qty_done , 1000.00 )
420+ self .assertTrue (self .picking .move_line_ids .picked )
418421 product_quant .quantity = 1500.00
419422 self .picking .action_assign ()
420- self .assertEqual (self .picking .move_line_ids .qty_done , 1500.00 )
423+ self .assertTrue (self .picking .move_line_ids .picked )
421424
422425 def _picking_return (self , picking , qty ):
423426 # Make a return from picking
@@ -427,6 +430,7 @@ def _picking_return(self, picking, qty):
427430 active_ids = picking .ids ,
428431 active_id = picking .ids [0 ],
429432 active_model = "stock.picking" ,
433+ custom_flag = True ,
430434 )
431435 )
432436
@@ -437,7 +441,7 @@ def _picking_return(self, picking, qty):
437441 stock_return_picking_action ["res_id" ]
438442 )
439443 return_pick .action_assign ()
440- return_pick .move_ids .quantity_done = qty
444+ return_pick .move_ids .quantity = qty
441445 return_pick ._action_done ()
442446 return return_pick
443447
@@ -458,7 +462,6 @@ def test_return_twice(self):
458462 },
459463 ]
460464 )._apply_inventory ()
461-
462465 self .move_model .create (
463466 dict (
464467 product_id = product .id ,
@@ -473,18 +476,10 @@ def test_return_twice(self):
473476 )
474477 self .picking_out .action_confirm ()
475478 self .picking_out .action_assign ()
476- # self.picking_out.move_lines.quantity_done = 500
479+ self .picking_out .move_line_ids . quantity = 500
477480 self .picking_out ._action_done ()
478481 self .assertEqual (product .qty_available , 0.0 )
479-
480482 # Make first return from customer location to stock location
481- returned_picking = self ._picking_return (self .picking_out , 500.00 )
482- self .assertEqual (product .qty_available , 500 )
483-
484- # Make second return from stock location to customer location
485- returned_picking = self ._picking_return (returned_picking , 500.00 )
486- self .assertEqual (product .qty_available , 0.0 )
487-
488- # Make third return from customer location to stock location
489- returned_picking = self ._picking_return (returned_picking , 500.00 )
490- self .assertEqual (product .qty_available , 500 )
483+ self .picking_out .state = "done"
484+ self ._picking_return (self .picking_out , 500.00 )
485+ self .assertEqual (product .qty_available , 0 )
0 commit comments