[FIX] website: nonexisting record id in URL =>404
Install the website_sale and open '/shop/whatever-9999' in your browser, the response is a 500 Internal Error instead of a 404 Page not Found. Because `request.endpoint` has been murdered by the httpocalypse, we must re-match to get the endpoint later used to re-build the URL. When an URL contains a record-id but that record does not exists, matching the URL will raise a `odoo.exceptions.MissingError`. Part-of: odoo/odoo#85340
This commit is contained in:
@@ -20,7 +20,7 @@ from odoo.addons.website.models.ir_http import sitemap_qs2dom
|
||||
from odoo.addons.website.tools import similarity_score, text_from_html
|
||||
from odoo.addons.portal.controllers.portal import pager
|
||||
from odoo.addons.iap.tools import iap_tools
|
||||
from odoo.exceptions import UserError, AccessError
|
||||
from odoo.exceptions import UserError, AccessError, MissingError
|
||||
from odoo.http import request
|
||||
from odoo.modules.module import get_resource_path, get_manifest
|
||||
from odoo.osv.expression import AND, OR, FALSE_DOMAIN, get_unaccent_wrapper
|
||||
@@ -1310,7 +1310,7 @@ class Website(models.Model):
|
||||
|
||||
router = http.root.get_db_router(request.db).bind('')
|
||||
path = router.build(rule.endpoint, args)
|
||||
except (NotFound, AccessError):
|
||||
except (NotFound, AccessError, MissingError):
|
||||
# The build method returns a quoted URL so convert in this case for consistency.
|
||||
path = urls.url_quote_plus(request.httprequest.path, safe='/')
|
||||
lang_path = f'/{lang.url_code}' if lang != self.default_lang_id else ''
|
||||
|
||||
Reference in New Issue
Block a user