[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:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user