diff --git a/addons/stock/models/stock_move.py b/addons/stock/models/stock_move.py index 0fb1ddbabbf..24e2c098eeb 100644 --- a/addons/stock/models/stock_move.py +++ b/addons/stock/models/stock_move.py @@ -1350,13 +1350,13 @@ class StockMove(models.Model): # Find a candidate move line to update or create a new one. for reserved_quant, quantity in quants: - to_update = self.move_line_ids.filtered(lambda ml: ml._reservation_is_updatable(quantity, reserved_quant)) + to_update = next((line for line in self.move_line_ids if line._reservation_is_updatable(quantity, reserved_quant)), False) if to_update: - uom_quantity = self.product_id.uom_id._compute_quantity(quantity, to_update[0].product_uom_id, rounding_method='HALF-UP') + uom_quantity = self.product_id.uom_id._compute_quantity(quantity, to_update.product_uom_id, rounding_method='HALF-UP') uom_quantity = float_round(uom_quantity, precision_digits=rounding) - uom_quantity_back_to_product_uom = to_update[0].product_uom_id._compute_quantity(uom_quantity, self.product_id.uom_id, rounding_method='HALF-UP') + uom_quantity_back_to_product_uom = to_update.product_uom_id._compute_quantity(uom_quantity, self.product_id.uom_id, rounding_method='HALF-UP') if to_update and float_compare(quantity, uom_quantity_back_to_product_uom, precision_digits=rounding) == 0: - to_update[0].with_context(bypass_reservation_update=True).product_uom_qty += uom_quantity + to_update.with_context(bypass_reservation_update=True).product_uom_qty += uom_quantity else: if self.product_id.tracking == 'serial': self.env['stock.move.line'].create([self._prepare_move_line_vals(quantity=1, reserved_quant=reserved_quant) for i in range(int(quantity))])