From ee0199cac4f58bc8aefd0ea1410d16fb6b9f4e31 Mon Sep 17 00:00:00 2001 From: jvm-odoo Date: Wed, 13 Nov 2019 09:17:49 +0000 Subject: [PATCH] [FIX] website_sale: removing invalid product from the cart Reproduce the issue: - Install eCommerce app - Publish a product to your website - Add the product in your cart - Unpublish/make unsellable/archive the product The product is still in the cart and the checkout process can be done. Cause: There is no check for invalid products before displaying the cart This commit remove the invalid products while loading the cart. OPW-2092541 closes odoo/odoo#40241 X-original-commit: ab9290e39c2d2b9eb6d6f9972c1c8b546263edfd Signed-off-by: Nicolas Martinelli (nim) --- addons/website_sale/controllers/main.py | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/website_sale/controllers/main.py b/addons/website_sale/controllers/main.py index 435ff2ce5d2..405cd3f5690 100644 --- a/addons/website_sale/controllers/main.py +++ b/addons/website_sale/controllers/main.py @@ -404,6 +404,7 @@ class WebsiteSale(http.Controller): 'suggested_products': [], }) if order: + order.order_line.filtered(lambda l: not l.product_id.active).unlink() _order = order if not request.env.context.get('pricelist'): _order = order.with_context(pricelist=order.pricelist_id.id)