[TEST] stock: add tests to pick a pack

This commit is contained in:
Pierre Masereel
2018-06-12 17:22:00 +02:00
parent 76bb1c60df
commit 4f04af5bab
+37 -1
View File
@@ -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')