[FIX] stock: allow changing scrap location with done moves
Before this commit: Modifying a location from/to a scrap location should be restricted when there are move lines with reservation. However, starting from Odoo 17, the quantity field indicates the reserved quantity only when the move line's state is different from done. After this commit: Only check if there are reservation lines (move lines not in done) in the location when changing from/to a scrap location to match the behaviour before Odoo 17. opw-3815275 closes odoo/odoo#159376 Signed-off-by: Quentin Wolfs (quwo) <quwo@odoo.com>
This commit is contained in:
@@ -207,6 +207,7 @@ class Location(models.Model):
|
||||
for f in {'usage', 'scrap_location'}))
|
||||
reserved_quantities = self.env['stock.move.line'].search_count([
|
||||
('location_id', 'in', modified_locations.ids),
|
||||
('state', 'not in', ['done', 'cancel']),
|
||||
('quantity_product_uom', '>', 0),
|
||||
])
|
||||
if reserved_quantities:
|
||||
|
||||
@@ -97,6 +97,21 @@ class TestRobustness(TransactionCase):
|
||||
move1._action_confirm()
|
||||
move1._action_assign()
|
||||
self.assertEqual(move1.state, 'assigned')
|
||||
|
||||
move2 = self.env['stock.move'].create({
|
||||
'name': 'test_location_archive',
|
||||
'location_id': test_stock_location.id,
|
||||
'location_dest_id': self.customer_location.id,
|
||||
'product_id': self.product1.id,
|
||||
'product_uom': self.uom_unit.id,
|
||||
'product_uom_qty': 1,
|
||||
})
|
||||
move2._action_confirm()
|
||||
move2._action_assign()
|
||||
move2.picked = True
|
||||
move2._action_done()
|
||||
self.assertEqual(move2.state, 'done')
|
||||
|
||||
quant = self.env['stock.quant']._gather(
|
||||
self.product1,
|
||||
test_stock_location,
|
||||
@@ -113,6 +128,7 @@ class TestRobustness(TransactionCase):
|
||||
|
||||
# unreserve
|
||||
move1._do_unreserve()
|
||||
test_stock_location.scrap_location = False
|
||||
|
||||
def test_package_unpack(self):
|
||||
""" Unpack a package that contains quants with a reservation
|
||||
|
||||
Reference in New Issue
Block a user