summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Masereel <pim@odoo.com>2018-06-12 16:12:33 +0200
committerPierre Masereel <pim@odoo.com>2018-06-12 17:22:00 +0200
commit4f04af5bab4200cd7e61a930f5db2f55e25fa80c (patch)
tree1fb04a04afceb501ea26f16bb43b4339e01ec4e9
parent76bb1c60dfc515849deba40a90a23e1f1c7c18ce (diff)
[TEST] stock: add tests to pick a pack
-rw-r--r--addons/stock/tests/test_packing.py38
1 files changed, 37 insertions, 1 deletions
diff --git a/addons/stock/tests/test_packing.py b/addons/stock/tests/test_packing.py
index 76fa956f287..7d7fc5c526c 100644
--- a/addons/stock/tests/test_packing.py
+++ b/addons/stock/tests/test_packing.py
@@ -68,6 +68,8 @@ class TestPacking(TransactionCase):
pick_picking.move_line_ids.filtered(lambda ml: ml.product_id == self.productB).qty_done = 2.0
first_pack = pick_picking.put_in_pack()
+ self.assertEquals(len(pick_picking.package_level_ids), 1, 'Put some products in pack should create a package_level')
+ self.assertEquals(pick_picking.package_level_ids[0].state, 'new', 'A new pack should be in state "new"')
pick_picking.move_line_ids.filtered(lambda ml: ml.product_id == self.productA and ml.qty_done == 0.0).qty_done = 4.0
pick_picking.move_line_ids.filtered(lambda ml: ml.product_id == self.productB and ml.qty_done == 0.0).qty_done = 3.0
second_pack = pick_picking.put_in_pack()
@@ -95,5 +97,39 @@ class TestPacking(TransactionCase):
'location_id': self.stock_location.id,
'location_dest_id': self.stock_location.id,
})
+ self.assertEquals(package_level.state, 'draft',
+ 'The package_level should be in draft as it has no moves, move lines and is not confirmed')
picking.action_confirm()
- self.assertEqual(len(picking.move_lines), 1, 'One move should be created when the package_level has been confirmed')
+ self.assertEqual(len(picking.move_lines), 1,
+ 'One move should be created when the package_level has been confirmed')
+ self.assertEquals(len(package_level.move_ids), 1,
+ 'The move should be in the package level')
+ self.assertEquals(package_level.state, 'confirmed',
+ 'The package level must be state confirmed when picking is confirmed')
+ picking.action_assign()
+ self.assertEqual(len(picking.move_lines), 1,
+ 'You still have only one move when the picking is assigned')
+ self.assertEqual(len(picking.move_lines.move_line_ids), 1,
+ 'The move should have one move line which is the reservation')
+ self.assertEquals(picking.move_line_ids.package_level_id.id, package_level.id,
+ 'The move line created should be linked to the package level')
+ self.assertEquals(picking.move_line_ids.package_id.id, pack.id,
+ 'The move line must have been reserved on the package of the package_level')
+ self.assertEquals(picking.move_line_ids.result_package_id.id, pack.id,
+ 'The move line must have the same package as result package')
+ self.assertEquals(package_level.state, 'assigned', 'The package level must be in state assigned')
+ package_level.write({'is_done': True})
+ self.assertEquals(len(package_level.move_line_ids), 1,
+ 'The package level should still keep one move line after have been set to "done"')
+ self.assertEquals(package_level.move_line_ids[0].qty_done, 20.0,
+ 'All quantity in package must be procesed in move line')
+ picking.button_validate()
+ self.assertEqual(len(picking.move_lines), 1,
+ 'You still have only one move when the picking is assigned')
+ self.assertEqual(len(picking.move_lines.move_line_ids), 1,
+ 'The move should have one move line which is the reservation')
+ self.assertEquals(package_level.state, 'done', 'The package level must be in state done')
+ self.assertEquals(pack.location_id.id, picking.location_dest_id.id,
+ 'The quant package must be in the destination location')
+ self.assertEquals(pack.quant_ids[0].location_id.id, picking.location_dest_id.id,
+ 'The quant must be in the destination location')