Skip to content
Snippets Groups Projects
Commit 5ba09c2c authored by Robin Lejeune (role)'s avatar Robin Lejeune (role)
Browse files

[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#135991

Signed-off-by: default avatarQuentin Smetz (qsm) <qsm@odoo.com>
parent e8683726
No related branches found
No related tags found
No related merge requests found
......@@ -21,7 +21,7 @@ class WebsiteVisitor(models.Model):
self.flush()
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:
......
......@@ -21,7 +21,7 @@
<field name="arch" type="xml">
<xpath expr="//button[@id='w_visitor_visit_counter']" position="before">
<button name="%(website_crm.website_visitor_crm_lead_action)d" type="action" class="oe_stat_button" icon="fa-star"
attrs="{'invisible': [('lead_count', '=', 0)]}">
groups="sales_team.group_sale_salesman" attrs="{'invisible': [('lead_count', '=', 0)]}">
<field name="lead_count" widget="statinfo" string="Leads"/>
</button>
</xpath>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment