diff --git a/addons/website_sale_stock/models/sale_order.py b/addons/website_sale_stock/models/sale_order.py index 391ad44b4af..169f97cba60 100644 --- a/addons/website_sale_stock/models/sale_order.py +++ b/addons/website_sale_stock/models/sale_order.py @@ -17,8 +17,11 @@ class SaleOrder(models.Model): for line in self.order_line: if line.product_id.type == 'product' and line.product_id.inventory_availability in ['always', 'threshold']: cart_qty = sum(self.order_line.filtered(lambda p: p.product_id.id == line.product_id.id).mapped('product_uom_qty')) - if cart_qty > line.product_id.with_context(warehouse=self.warehouse_id.id).virtual_available and (line_id == line.id): - qty = line.product_id.with_context(warehouse=self.warehouse_id.id).virtual_available - cart_qty + # The quantity should be computed based on the warehouse of the website, not the + # warehouse of the SO. + website = self.env['website'].get_current_website() + if cart_qty > line.product_id.with_context(warehouse=website.warehouse_id.id).virtual_available and (line_id == line.id): + qty = line.product_id.with_context(warehouse=website.warehouse_id.id).virtual_available - cart_qty new_val = super(SaleOrder, self)._cart_update(line.product_id.id, line.id, qty, 0, **kwargs) values.update(new_val)