From ada423558220375f1cbc49268dcc0b94b8efa0b2 Mon Sep 17 00:00:00 2001 From: tslai Date: Wed, 23 May 2018 08:11:17 +0000 Subject: [PATCH] [FIX] website_sale_wishlist: avoid traceback when product has been unpublished Before this commit, if you add in your wishlist a product, and that this product become unpublished, the user will have a traceback. After this commit, we filter the wishlist product to only show published product. This commit closes #24857 and closes #24618 --- addons/website_sale_wishlist/models/product_wishlist.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/addons/website_sale_wishlist/models/product_wishlist.py b/addons/website_sale_wishlist/models/product_wishlist.py index 6c73cf50608..381d5eceb45 100644 --- a/addons/website_sale_wishlist/models/product_wishlist.py +++ b/addons/website_sale_wishlist/models/product_wishlist.py @@ -36,14 +36,15 @@ class ProductWishlist(models.Model): @api.model def current(self): - """Get all wishlist items that belong to current user or session.""" - return self.search([ + """Get all wishlist items that belong to current user or session, + filter products that are unpublished.""" + return self.sudo().search([ "|", ("partner_id", "=", self.env.user.partner_id.id), "&", ("partner_id", "=", False), ("session", "=", self.env.user.current_session), - ]) + ]).filtered('product_id.product_tmpl_id.website_published') @api.model def _add_to_wishlist(self, pricelist_id, currency_id, website_id, price, product_id, partner_id=False, session=False):