From 8d0625a95f42c1e5cd0920409d0a03367700863b Mon Sep 17 00:00:00 2001 From: "Eteil Djoumatchoua(etdj)" Date: Tue, 13 Jun 2023 09:07:43 +0000 Subject: [PATCH] [FIX] website_sale: add product with extra price to cart Version: 16.0 Prerequisites: - "Pricelist" enabled - "Prevent Sale of Zero Priced Product" enabled Steps: - Create a product: - Sales Price: 0 - In the "Sales" tab set "website" to a website - Add Extra Prices (smart button) - Public Pricelist (USD) - Min. Quantity: 0 - Price: 100 - Go to the shop, choose the correct pricelist and try to add the product to the cart Issue: UserError: The given product does not have a price therefore it cannot be added to cart. Cause: It doesn't compare the good price list considering the context opw-3339524 closes odoo/odoo#124898 X-original-commit: facd44d0bd4352be3d0eb11a2675e7a518c97e59 Signed-off-by: Victor Feyens (vfe) --- addons/website_sale/models/sale_order.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/addons/website_sale/models/sale_order.py b/addons/website_sale/models/sale_order.py index 4bcf08dfa3e..1d21faea6ce 100644 --- a/addons/website_sale/models/sale_order.py +++ b/addons/website_sale/models/sale_order.py @@ -166,9 +166,6 @@ class SaleOrder(models.Model): if add_qty and (not product or not product._is_add_to_cart_allowed()): raise UserError(_("The given product does not exist therefore it cannot be added to cart.")) - if product.lst_price == 0 and product.website_id.prevent_zero_price_sale: - raise UserError(_("The given product does not have a price therefore it cannot be added to cart.")) - if line_id is not False: order_line = self._cart_find_product_line(product_id, line_id, **kwargs)[:1] else: @@ -211,6 +208,11 @@ class SaleOrder(models.Model): order_line = self._cart_update_order_line(product_id, quantity, order_line, **kwargs) + if order_line and order_line.price_unit == 0 and self.website_id.prevent_zero_price_sale: + raise UserError(_( + "The given product does not have a price therefore it cannot be added to cart.", + )) + return { 'line_id': order_line.id, 'quantity': quantity,