I have the following code and I need to update the total quantity of products in all warehouses. Unfortunately the solution below doesn’t work, although I looked at the documentation from GitHub and it seems to work: api-docs/resources/products.md at master · VeeqoAPI/api-docs · GitHub.
quantity = sellable.get('available_stock_level_at_all_warehouses')
new_quantity = int(quantity) - product.quantity
if new_quantity < 0:
logger.warning(f'New quantity for SKU {product.sku} would be negative. Skipping update.')
continue
update_data = {
'product': {
'product_variants_attributes': [
{
'id': sellable['id'],
'available_stock_level_at_all_warehouses': new_quantity
}
]
}
}
task = self.client.put(url, headers=headers, data=update_data)
tasks.append(task)