diff --git a/addons/stock/models/stock_move.py b/addons/stock/models/stock_move.py index be50495305d..3054f09ef7a 100644 --- a/addons/stock/models/stock_move.py +++ b/addons/stock/models/stock_move.py @@ -816,7 +816,8 @@ 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 m: m.location_id.id == reserved_quant.location_id.id and m.lot_id.id == reserved_quant.lot_id.id and m.package_id.id == reserved_quant.package_id.id and m.owner_id.id == reserved_quant.owner_id.id) + to_update = self.move_line_ids.filtered(lambda m: m.product_id.tracking != 'serial' and + m.location_id.id == reserved_quant.location_id.id and m.lot_id.id == reserved_quant.lot_id.id and m.package_id.id == reserved_quant.package_id.id and m.owner_id.id == reserved_quant.owner_id.id) if to_update: to_update[0].with_context(bypass_reservation_update=True).product_uom_qty += self.product_id.uom_id._compute_quantity(quantity, self.product_uom, rounding_method='HALF-UP') else: diff --git a/addons/stock/tests/test_move.py b/addons/stock/tests/test_move.py index 0e52a87d1ca..9b011f34164 100644 --- a/addons/stock/tests/test_move.py +++ b/addons/stock/tests/test_move.py @@ -756,6 +756,28 @@ class StockMove(TransactionCase): self.assertEqual(customer_quants.quantity, 30) self.assertEqual(customer_quants.reserved_quantity, 0) + def test_availability_5(self): + """ Check that rerun action assign only create new stock move + lines instead of adding quantity in existing one. + """ + self.env['stock.quant']._update_available_quantity(self.product2, self.stock_location, 2.0) + # move from shelf1 + move = self.env['stock.move'].create({ + 'name': 'test_edit_moveline_1', + 'location_id': self.stock_location.id, + 'location_dest_id': self.customer_location.id, + 'product_id': self.product2.id, + 'product_uom': self.uom_unit.id, + 'product_uom_qty': 4.0, + }) + move._action_confirm() + move._action_assign() + + self.env['stock.quant']._update_available_quantity(self.product2, self.stock_location, 4.0) + move._action_assign() + + self.assertEqual(len(move.move_line_ids), 4.0) + def test_unreserve_1(self): """ Check that unreserving a stock move sets the products reserved as available and set the state back to confirmed.