summaryrefslogtreecommitdiff
path: root/addons/project/controllers
diff options
context:
space:
mode:
authorMartin Trigaux <mat@odoo.com>2018-10-09 13:01:27 +0000
committerMartin Trigaux <mat@odoo.com>2018-10-09 14:14:31 +0000
commit9f209dd77ea71cd45a9eab7f1d7424a81e0f9489 (patch)
tree6b41afd9b6d379b2e36503a889b5d8da55640756 /addons/project/controllers
parenta277bfb44a725f201b728dfc79515a01c0a29f6a (diff)
[FIX] project: do not crash when no result
If the selected project has no task (e.g. new project), still make a search. The previous code was making a KeyError on the filterby as the read_group returned no result. Introduced at d5bc0e57cd9288dc7 As a portal, a user may have access to some projects (when set explicitly as the customer on the project configuration). Make this with a first search and add the other tasks also with the read_group in case the user has access to some tasks but not the project. Fixes #27457 closes odoo/odoo#27581
Diffstat (limited to 'addons/project/controllers')
-rw-r--r--addons/project/controllers/portal.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/addons/project/controllers/portal.py b/addons/project/controllers/portal.py
index aae45fa9805..03830451911 100644
--- a/addons/project/controllers/portal.py
+++ b/addons/project/controllers/portal.py
@@ -121,9 +121,18 @@ class CustomerPortal(CustomerPortal):
'none': {'input': 'none', 'label': _('None')},
'project': {'input': 'project', 'label': _('Project')},
}
+
+ # extends filterby criteria with project the customer has access to
+ projects = request.env['project.project'].search([])
+ for project in projects:
+ searchbar_filters.update({
+ str(project.id): {'label': project.name, 'domain': [('project_id', '=', project.id)]}
+ })
+
# extends filterby criteria with project (criteria name is the project id)
# Note: portal users can't view projects they don't follow
- project_groups = request.env['project.task'].read_group([], ['project_id'], ['project_id'])
+ project_groups = request.env['project.task'].read_group([('project_id', 'not in', project.ids)],
+ ['project_id'], ['project_id'])
for group in project_groups:
proj_id = group['project_id'][0] if group['project_id'] else False
proj_name = group['project_id'][1] if group['project_id'] else _('Others')