[FIX] stock: use package location for package level source location

X-original-commit: c923baa99e41035326d1fc9c0443670214159967
This commit is contained in:
William Henrotin
2020-11-30 15:25:10 +00:00
parent a55e636743
commit 5bea8ed996
2 changed files with 7 additions and 5 deletions
+3 -1
View File
@@ -183,11 +183,13 @@ class StockPackageLevel(models.Model):
all_in = False
return all_in
@api.depends('state', 'is_fresh_package', 'move_ids', 'move_line_ids')
@api.depends('package_id', 'state', 'is_fresh_package', 'move_ids', 'move_line_ids')
def _compute_location_id(self):
for pl in self:
if pl.state == 'new' or pl.is_fresh_package:
pl.location_id = False
elif pl.package_id:
pl.location_id = pl.package_id.location_id
elif pl.state == 'confirmed' and pl.move_ids:
pl.location_id = pl.move_ids[0].location_id
elif pl.state in ('assigned', 'done') and pl.move_line_ids:
+4 -4
View File
@@ -181,22 +181,22 @@ class TestPacking(TestPackingCommon):
'company_id': picking.company_id.id,
})
picking.action_confirm()
self.assertEqual(picking.package_level_ids.mapped('location_id.id'), [self.stock_location.id],
self.assertEqual(picking.package_level_ids.mapped('location_id.id'), [shelf1_location.id],
'The package levels should still in the same location after confirmation.')
picking.action_assign()
package_level_reserved = picking.package_level_ids.filtered(lambda pl: pl.state == 'assigned')
package_level_confirmed = picking.package_level_ids.filtered(lambda pl: pl.state == 'confirmed')
self.assertEqual(package_level_reserved.location_id.id, shelf1_location.id, 'The reserved package level must be reserved in shelf1')
self.assertEqual(package_level_confirmed.location_id.id, self.stock_location.id, 'The not reserved package should keep its location')
self.assertEqual(package_level_confirmed.location_id.id, shelf1_location.id, 'The not reserved package should keep its location')
picking.do_unreserve()
self.assertEqual(picking.package_level_ids.mapped('location_id.id'), [self.stock_location.id],
self.assertEqual(picking.package_level_ids.mapped('location_id.id'), [shelf1_location.id],
'The package levels should have back the original location.')
picking.package_level_ids.write({'is_done': True})
picking.action_assign()
package_level_reserved = picking.package_level_ids.filtered(lambda pl: pl.state == 'assigned')
package_level_confirmed = picking.package_level_ids.filtered(lambda pl: pl.state == 'confirmed')
self.assertEqual(package_level_reserved.location_id.id, shelf1_location.id, 'The reserved package level must be reserved in shelf1')
self.assertEqual(package_level_confirmed.location_id.id, self.stock_location.id, 'The not reserved package should keep its location')
self.assertEqual(package_level_confirmed.location_id.id, shelf1_location.id, 'The not reserved package should keep its location')
self.assertEqual(picking.package_level_ids.mapped('is_done'), [True, True], 'Both package should still done')
def test_put_in_pack_to_different_location(self):