[FIX] website_sale: unpublished recently viewed cause access error
1. Login as admin 2. Go to any product page and click Personalize > Enable recently viewed products 3. Login in another browser session as portal user 4. Open some products until you start seeing the recently viewed products 5. With the admin account unpublish one of the recently viewed 6. On the portal account browse more to display the recently viewed Access error will raise because an unpublished product is requested by the user. Filtering the product to allow only published products fix the issue. opw-2336699 closes odoo/odoo#57836 X-original-commit: 668778125c2d4231d9b48456c3397edb8d04acb3 Signed-off-by: agr-odoo <agr-odoo@users.noreply.github.com>
This commit is contained in:
@@ -1214,7 +1214,7 @@ class WebsiteSale(http.Controller):
|
||||
if visitor:
|
||||
excluded_products = request.website.sale_get_order().mapped('order_line.product_id.id')
|
||||
products = request.env['website.track'].sudo().read_group(
|
||||
[('visitor_id', '=', visitor.id), ('product_id', '!=', False), ('product_id', 'not in', excluded_products)],
|
||||
[('visitor_id', '=', visitor.id), ('product_id', '!=', False), ('product_id.website_published', '=', True), ('product_id', 'not in', excluded_products)],
|
||||
['product_id', 'visit_datetime:max'], ['product_id'], limit=max_number_of_product_for_carousel, orderby='visit_datetime DESC')
|
||||
products_ids = [product['product_id'][0] for product in products]
|
||||
if products_ids:
|
||||
|
||||
Reference in New Issue
Block a user