From 06e264e9cac3b6e3703a16d94ca162fc5ebb5c4d Mon Sep 17 00:00:00 2001 From: Jordi Ballester Date: Tue, 11 May 2021 20:05:20 +0000 Subject: [PATCH] [FIX] project: portal access error - Install project - Ceate an internal user without any access rights - Go to `/my` A 500 error is raised because of an AccessError. When the user has no access rights to any of the mentioned applications, the `search` call returns an AccessError. We prevent the access error and return 0 as a fallback. closes odoo/odoo#89648 X-original-commit: 53334071d3073e0404bb981e1309d351f5e3ab43 Signed-off-by: Yannick Tivisse (yti) --- addons/project/controllers/portal.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/project/controllers/portal.py b/addons/project/controllers/portal.py index 9919dd67b74..b57408aefa9 100644 --- a/addons/project/controllers/portal.py +++ b/addons/project/controllers/portal.py @@ -20,9 +20,11 @@ class ProjectCustomerPortal(CustomerPortal): def _prepare_home_portal_values(self, counters): values = super()._prepare_home_portal_values(counters) if 'project_count' in counters: - values['project_count'] = request.env['project.project'].search_count([]) + values['project_count'] = request.env['project.project'].search_count([]) \ + if request.env['project.project'].check_access_rights('read', raise_exception=False) else 0 if 'task_count' in counters: - values['task_count'] = request.env['project.task'].search_count([]) + values['task_count'] = request.env['project.task'].search_count([]) \ + if request.env['project.task'].check_access_rights('read', raise_exception=False) else 0 return values # ------------------------------------------------------------