From cce6030c0da77a5739af01d57cd53822fc3ab394 Mon Sep 17 00:00:00 2001 From: Simon Lejeune Date: Wed, 2 May 2018 20:36:22 +0200 Subject: [PATCH] [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 opw 1837900 [0] e1cea2640fc064a56b0dba4f79e6b8a91a48b4fc [1] 0469d2e7126c46e019ed5f4233ef7b20d3499a0e --- addons/stock/models/stock_move.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/stock/models/stock_move.py b/addons/stock/models/stock_move.py index 3abf0979c0a..358f3ab9d2f 100644 --- a/addons/stock/models/stock_move.py +++ b/addons/stock/models/stock_move.py @@ -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):