[IMP] base: check fallback on AccessDenied

Before this commit, we only check if another endpoint can be serve in case of
404 not found. Idea was that each url has only one endpoint.

Fun effect is that if record doesn't exist, route doesn't match, so in reality
we had one endpoint but we fallback too to check if another match.

But it doesn't match a recurring case, when you archive a record, and want to
create a redirect for your seo and customer to another record, it is just
ignored because the url math a controller (that return 403 since you don't have
anymore the access right)

Since ask to the customer to delete the record is not always possible
(e.g. a product already sold) now we check if a fallback match for 403.

closes odoo/odoo#66030

Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
This commit is contained in:
Jeremy Kersten
2021-02-12 08:46:31 +00:00
parent ff8070033b
commit 3b9cd53660
+2 -1
View File
@@ -191,7 +191,8 @@ class IrHttp(models.AbstractModel):
# This is done first as the attachment path may
# not match any HTTP controller
if isinstance(exception, werkzeug.exceptions.HTTPException) and exception.code == 404:
if (isinstance(exception, werkzeug.exceptions.HTTPException) and exception.code == 404) or \
(isinstance(exception, odoo.exceptions.AccessError)):
serve = cls._serve_fallback(exception)
if serve:
return serve