diff --git a/stock_move_location/tests/test_common.py b/stock_move_location/tests/test_common.py index a72e5c9f3..9a352f4ec 100644 --- a/stock_move_location/tests/test_common.py +++ b/stock_move_location/tests/test_common.py @@ -120,10 +120,21 @@ class TestsCommon(common.SavepointCase): def set_product_amount( self, product, location, amount, lot_id=None, package_id=None, owner_id=None ): + """Set available stock Quantity to 'amount'""" + current_qty = self.env["stock.quant"]._get_available_quantity( + product, + location, + lot_id=lot_id, + package_id=package_id, + owner_id=owner_id, + ) + # Since _update_available_quantity decreases or increases, + # we need to first get the current amount. + change_amount = amount - current_qty self.env["stock.quant"]._update_available_quantity( product, location, - amount, + change_amount, lot_id=lot_id, package_id=package_id, owner_id=owner_id,