Adjust stock levels for products using inventory adjustments.
Use this skill to manually adjust the quantity of products in stock.
from scripts.config import search_read
product_id = 123
location_id = 8 # Standard 'Stock' location usually (e.g., WH/Stock)
# Find existing quant
quants = search_read('stock.quant',
[('product_id', '=', product_id), ('location_id', '=', location_id)],
['id', 'quantity', 'inventory_quantity']
)
from scripts.config import write, call_button
quant_id = quants[0]['id']
new_quantity = 50.0
# Set Counted Quantity
write('stock.quant', quant_id, {'inventory_quantity': new_quantity})
# Apply Adjustment
call_button('stock.quant', [quant_id], 'action_apply_inventory')
print(f"Adjusted stock for quant {quant_id} to {new_quantity}")
from scripts.config import create
# Create quant if it doesn't exist
quant_id = create('stock.quant', {
'product_id': product_id,
'location_id': location_id,
'inventory_quantity': 10.0,
})
# Apply
call_button('stock.quant', [quant_id], 'action_apply_inventory')