[IMP] stock_move_location tests: _set_product_amount should actually set the amount and not increase/decrease

This commit is contained in:
Joshua Kreuder
2023-01-20 12:00:35 +01:00
parent e9fb7bfe09
commit 0f8104b77d

View File

@@ -120,10 +120,21 @@ class TestsCommon(common.SavepointCase):
def set_product_amount( def set_product_amount(
self, product, location, amount, lot_id=None, package_id=None, owner_id=None 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( self.env["stock.quant"]._update_available_quantity(
product, product,
location, location,
amount, change_amount,
lot_id=lot_id, lot_id=lot_id,
package_id=package_id, package_id=package_id,
owner_id=owner_id, owner_id=owner_id,