[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) <nim@odoo.com>
This commit is contained in:
jvm-odoo
2019-11-14 09:11:26 +00:00
committed by fw-bot
parent 67044d64cd
commit ee0199cac4
+1
View File
@@ -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)