[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
This commit is contained in:
tslai
2018-06-11 12:56:40 +02:00
committed by Jeremy Kersten
parent 91bcd84a02
commit ada4235582
@@ -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):