diff --git a/addons/stock/models/stock_move.py b/addons/stock/models/stock_move.py index 735f0c53f94..25cc6163c9c 100644 --- a/addons/stock/models/stock_move.py +++ b/addons/stock/models/stock_move.py @@ -897,8 +897,11 @@ class StockMove(models.Model): """ assigned_moves = self.env['stock.move'] partially_available_moves = self.env['stock.move'] + # Read the `reserved_availability` field of the moves out of the loop to prevent unwanted + # cache invalidation when actually reserving the move. + reserved_availability = {move: move.reserved_availability for move in self} for move in self.filtered(lambda m: m.state in ['confirmed', 'waiting', 'partially_available']): - missing_reserved_uom_quantity = move.product_uom_qty - move.reserved_availability + missing_reserved_uom_quantity = move.product_uom_qty - reserved_availability[move] missing_reserved_quantity = move.product_uom._compute_quantity(missing_reserved_uom_quantity, move.product_id.uom_id, rounding_method='HALF-UP') if move.location_id.should_bypass_reservation()\ or move.product_id.type == 'consu':