[FIX] stock: symmetric reserve and unreserve
When an internal locations has its `scrapped` field set to True, reserving will increment the quant's `reserved_quantity` while unreserving will bypass the reservation mechanism (as in a supplier location). This leads to a desynchronisation between the partially_available/available move lines and the quant's `reserved_quantity`, leading later on to "cannot unreserve more than available" errors. To prevent this kind of issues, there's a `should_bypass_reservation` method set on the location that we *should* use everywhere, it was implemented by [0]. Sadly, this line was not adapted since its implementaton in [1]. Co-authored by len-odoo <len@odoo.com> opw 1837900 [0]e1cea2640f[1]0469d2e712
This commit is contained in:
@@ -895,7 +895,7 @@ class StockMove(models.Model):
|
||||
assigned_moves = self.env['stock.move']
|
||||
partially_available_moves = self.env['stock.move']
|
||||
for move in self.filtered(lambda m: m.state in ['confirmed', 'waiting', 'partially_available']):
|
||||
if move.location_id.usage in ('supplier', 'inventory', 'production', 'customer')\
|
||||
if move.location_id.should_bypass_reservation()\
|
||||
or move.product_id.type == 'consu':
|
||||
# create the move line(s) but do not impact quants
|
||||
if move.product_id.tracking == 'serial' and (move.picking_type_id.use_create_lots or move.picking_type_id.use_existing_lots):
|
||||
|
||||
Reference in New Issue
Block a user