Skip to content
Snippets Groups Projects
Commit 4cdea395 authored by Victor Piryns (pivi)'s avatar Victor Piryns (pivi)
Browse files

[FIX] project: ignore sort key in url args when it's invalid


Issue:
In the project's portal view, if the user is previewing his tasks of a
project with a specific order that is not date or name, and then
goes back to the project list view via the breadcrumb, he is met
with an error 500.

Steps to reproduce:
- Install Project
- With the portal user, go to Project
- Click on a project and sort the task by 'project'
- Go back to the project view via the breadcrumbs.
- Error 500

Cause:
Due to the definition of the url of the breadcrumbs which is
set with `keep_query` which keeps the arguments of the url. The
issue with that is that for the project list view, some of the sort
arguments are not defined, as they are only present in the task view.
So if we sort based on 'project' there is a `KeyError` in the
controller of the project portal view.

Fix:
If the `sortby` is not one of the valid keys, we fallback on 'date'
sorting, which is the behaviour in case when there is no `sortby`
argument in the url. This will keep the `sortby` in the arguments of
the URL, but just ignoring it. This is better UX than having a hard
redirection, because if the user decides to click on a project, the
tasks will be sorted with his previous order specified, which is
usually the wanted behaviour.

Affected versions:
15.0 -> 16.0

opw-3425342

closes odoo/odoo#133642

X-original-commit: 00126875
Signed-off-by: default avatarXavier Bol (xbo) <xbo@odoo.com>
Signed-off-by: default avatarPiryns Victor (pivi) <pivi@odoo.com>
parent 3255a0d5
No related branches found
No related tags found
No related merge requests found
......@@ -69,7 +69,7 @@ class ProjectCustomerPortal(CustomerPortal):
domain = self._prepare_project_domain()
searchbar_sortings = self._prepare_searchbar_sortings()
if not sortby:
if not sortby or sortby not in searchbar_sortings:
sortby = 'date'
order = searchbar_sortings[sortby]['order']
......
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