From 4a4d6017d9046f9de8baa7a479c7f03a910b8958 Mon Sep 17 00:00:00 2001 From: "Robin Lejeune (role)" <role@odoo.com> Date: Mon, 18 Sep 2023 14:54:52 +0000 Subject: [PATCH] [FIX] website_crm: fix access error for users without CRM rights 1. Backport of [1]. 2. Steps to reproduce: - Install website_crm - Connect as Admin and remove the sales rights for Demo - Check the website on a private window (to create an anonymous visit) - Connect as Demo on the normal window - Go to Website > Reporting > Visitors => It triggers an access error due to lead_ids being restricted to sales_team.group_sale_salesman. (Note: the error sometimes isn't triggered at that point. In that case, click on the visitor: the same error will trigger.) Considering the computed field doesn't do anything critical as it just retrieves the email and phone number, the restriction is overridden on the field. [1]: https://github.com/odoo/odoo/commit/7de453477d7c23e607a15e0d60613080857e3371 opw-3475301 closes odoo/odoo#136353 X-original-commit: 70faf9bb07c9d801b3b06b325fc33de66c8406f3 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com> Signed-off-by: Robin Lejeune (role) <role@odoo.com> --- addons/website_crm/models/website_visitor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/website_crm/models/website_visitor.py b/addons/website_crm/models/website_visitor.py index c990a7ab1fff..18bf191c8821 100644 --- a/addons/website_crm/models/website_visitor.py +++ b/addons/website_crm/models/website_visitor.py @@ -21,7 +21,7 @@ class WebsiteVisitor(models.Model): super(WebsiteVisitor, self)._compute_email_phone() left_visitors = self.filtered(lambda visitor: not visitor.email or not visitor.mobile) - leads = left_visitors.mapped('lead_ids').sorted('create_date', reverse=True) + leads = left_visitors.sudo().mapped('lead_ids').sorted('create_date', reverse=True) visitor_to_lead_ids = dict((visitor.id, visitor.lead_ids.ids) for visitor in left_visitors) for visitor in left_visitors: -- GitLab