From 8d229f22b36b24bea37111bce2277c79c36213b9 Mon Sep 17 00:00:00 2001 From: "Thomas Lefebvre (thle)" Date: Tue, 10 Jan 2023 14:20:16 +0000 Subject: [PATCH] [FIX] website_sale: remove reward line from cart Steps to reproduce: - go to e-commerce; - add a product to the cart; - add a gift card; - remove the gift card form the cart. (the user must not belong to the group 'base.group_system') Issue: A user error appears. Cause: The gift card is a product that cannot be added to the cart like the others. Therefore, an error is triggered. Solution: Make the error trigger only when adding products to the cart. opw-3114090 closes odoo/odoo#109654 X-original-commit: 9cc699b89688261220aeb39a99fd866c27808d0a Signed-off-by: William Braeckman (wbr) Signed-off-by: Lefebvre Thomas (thle) --- addons/website_sale/models/sale_order.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/website_sale/models/sale_order.py b/addons/website_sale/models/sale_order.py index 608bd3a7ae4..3fc0446a6e4 100644 --- a/addons/website_sale/models/sale_order.py +++ b/addons/website_sale/models/sale_order.py @@ -129,7 +129,7 @@ class SaleOrder(models.Model): raise UserError(_('It is forbidden to modify a sales order which is not in draft status.')) product = self.env['product.product'].browse(product_id).exists() - if not product or not product._is_add_to_cart_allowed(): + 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: