From 937e0bd7109ccd4c0e595eaea2f96ea8a737cbfd Mon Sep 17 00:00:00 2001 From: nie Date: Wed, 10 Mar 2021 10:11:17 +0000 Subject: [FIX] website_sale: only show products of the current companies Steps: - Create a second company - Go to Website > Products > Products - Create a product for all companies - Click the "Go to Website" smart button - Click "Edit in Backend" in the top-right corner - Change the product's company to the one you're not on - Go to Visitors > Visitors Bug: Access Error: The requested operation ("read" on "Product" (product.product)) was rejected because of the following rules: (Records: Two prod (id=42), User: Mitchell Admin (id=2)) Explanation: It happens because of the rule `product_comp_rule` which prevents reading a product from a different company. This commit filters the visited products on the current companies. opw:2467138 closes odoo/odoo#67603 X-original-commit: 984adb180ab1a255fac086fd61478141074e8d31 Signed-off-by: Nicolas Lempereur (nle) Signed-off-by: backspac --- addons/website_sale/models/website_visitor.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/website_sale/models/website_visitor.py b/addons/website_sale/models/website_visitor.py index 7fc2a2d5075..24461058569 100644 --- a/addons/website_sale/models/website_visitor.py +++ b/addons/website_sale/models/website_visitor.py @@ -21,7 +21,10 @@ class WebsiteVisitor(models.Model): @api.depends('website_track_ids') def _compute_product_statistics(self): results = self.env['website.track'].read_group( - [('visitor_id', 'in', self.ids), ('product_id', '!=', False)], ['visitor_id', 'product_id'], ['visitor_id', 'product_id'], lazy=False) + [('visitor_id', 'in', self.ids), ('product_id', '!=', False), + '|', ('product_id.company_id', 'in', self.env.companies.ids), ('product_id.company_id', '=', False)], + ['visitor_id', 'product_id'], ['visitor_id', 'product_id'], + lazy=False) mapped_data = {} for result in results: visitor_info = mapped_data.get(result['visitor_id'][0], {'product_count': 0, 'product_ids': set()}) -- cgit v1.2.3