[FIX] website_project_issue: apply f0e557c to count controller

The goal is to display the number of issues that are in projects
with a "portal" privacy setting. However, this setting is used by a
record rule to limit access to the project to followers only; this
means that you should add all the customers who submit issues to your
support project. This makes no sense.

To circumvent this problem, the domain of projects with this visibility
setting is fetched as sudo.
This commit is contained in:
Damien Bouvy
2016-09-13 15:21:43 +02:00
parent 5b146c6836
commit 1dd5c50651
@@ -14,7 +14,9 @@ class WebsiteAccount(website_account):
def _prepare_portal_layout_values(self):
values = super(WebsiteAccount, self)._prepare_portal_layout_values()
# domain is needed to hide non portal project for employee
issue_count = request.env['project.issue'].search_count([('project_id.privacy_visibility','=','portal')])
# portal users can't see the privacy_visibility, fetch the domain for them in sudo
portal_projects = request.env['project.project'].sudo().search([('privacy_visibility', '=', 'portal')])
issue_count = request.env['project.issue'].search_count([('project_id', 'in', portal_projects.ids)])
values.update({
'issue_count': issue_count,
})