[FIX] website_hr_recruitment: redirect deprecated /jobs routes

__Current behavior before commit:__
`/jobs` routes have been modified in [this commit][1]. Old ones are
deprecated but are still working for backward compatibility.

When searching on this page, search params are now just added at the end
of the URL (instead of being part of the path like before).
If the URL of the page is a deprecated one, this can create a conflict
with the previous way the params were handled and produce an error.

__Description of the fix:__
Redirect the user to the new route any time he tries to reach the
deprecated ones. Any parameters included in the old URL will be carried
over to the new route to maintain expected behavior. If a parameter is
provided both in the path and as a kwarg, the kwarg value will take
precedence.

__Steps to reproduce the issue on runbot:__
1. Go to `/jobs/country/20`
2. Make a search using the search bar -> Crash

opw-3781374

[1]: https://github.com/odoo/odoo/commit/54f246f9c75b8f1ebdc637c6000f3e4773d702d5

closes odoo/odoo#157079

X-original-commit: 5a9ce2d7773222ac8989e3172f9363a7d6f71871
Signed-off-by: Sofie Gvaladze (sgv) <sgv@odoo.com>
Signed-off-by: Julien Launois (jula) <jula@odoo.com>
This commit is contained in:
Julien (jula)
2024-03-08 19:48:00 +00:00
parent 5f454dc140
commit 41676cd170
@@ -3,6 +3,7 @@
import warnings
from datetime import datetime, timedelta
from werkzeug.urls import url_encode
from odoo import http, _
from odoo.addons.http_routing.models.ir_http import slug
@@ -271,12 +272,16 @@ class WebsiteHrRecruitment(http.Controller):
"This route is deprecated since Odoo 16.3: the jobs list is now available at /jobs or /jobs/page/XXX",
DeprecationWarning
)
return self.jobs(
country_id=country.id if country else None,
department_id=department.id if department else None,
office_id=office_id,
contract_type_id=contract_type_id,
**kwargs
url_params = {
'country_id': country and country.id,
'department_id': department and department.id,
'office_id': office_id,
'contract_type_id': contract_type_id,
**kwargs,
}
return request.redirect(
'/jobs?%s' % url_encode(url_params),
code=301,
)
@http.route('/website_hr_recruitment/check_recent_application', type='json', auth="public")