summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authornie <nie@odoo.com>2021-03-10 10:11:17 +0000
committernie <nie@odoo.com>2021-03-10 15:15:31 +0000
commit937e0bd7109ccd4c0e595eaea2f96ea8a737cbfd (patch)
tree14862345de970cd79e3ceec0b21a6171b7b4dbd6 /addons
parent8ca3ea063050f2ab2d19cce8a68116489872a734 (diff)
[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) <nle@odoo.com> Signed-off-by: backspac <backspac@users.noreply.github.com>
Diffstat (limited to 'addons')
-rw-r--r--addons/website_sale/models/website_visitor.py5
1 files changed, 4 insertions, 1 deletions
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()})