summaryrefslogtreecommitdiff
path: root/addons/http_routing
diff options
context:
space:
mode:
authorJeremy Kersten <jke@odoo.com>2019-11-15 08:19:43 +0000
committerJeremy Kersten <jke@odoo.com>2019-11-26 14:35:46 +0000
commitdc77f67cad95d0b0bd316cbdfc36a380f2daf73d (patch)
tree2a72a21f498ca6f984af7f230852a62a5f5ecfe5 /addons/http_routing
parentef0488ef91161eba5267ea29fa5c6b379c483f29 (diff)
[FIX] website: match get/post in is_multilang_url
Old heuristic is not more True: Force to check method to POST. Odoo uses methods : ['POST'] and ['GET', 'POST'] We have some controller that only allow 'GET' method, so we need to check GET also when we try to know if an url is multilang or not. This commit fix case where a controller '/test' only allow GET and you were in another language that the default, in this case, the rendered url in qweb was /get instead of /<lang>/get. Closes #37223 closes odoo/odoo#40519 X-original-commit: c7650106f8588083be12812600a6c94ba703fd6f Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
Diffstat (limited to 'addons/http_routing')
-rw-r--r--addons/http_routing/models/ir_http.py24
1 files changed, 15 insertions, 9 deletions
diff --git a/addons/http_routing/models/ir_http.py b/addons/http_routing/models/ir_http.py
index 988a50000cc..983761c8b8f 100644
--- a/addons/http_routing/models/ir_http.py
+++ b/addons/http_routing/models/ir_http.py
@@ -222,23 +222,29 @@ def is_multilang_url(local_url, lang_url_codes=None):
if spath[1] in lang_url_codes:
spath.pop(1)
local_url = '/'.join(spath)
+
+ url = local_url.partition('#')[0].split('?')
+ path = url[0]
+ query_string = url[1] if len(url) > 1 else None
+ router = request.httprequest.app.get_db_router(request.db).bind('')
+
+ def is_multilang_func(func):
+ return (func and func.routing.get('website', False) and
+ func.routing.get('multilang', func.routing['type'] == 'http'))
+ # Try to match an endpoint in werkzeug's routing table
try:
- # Try to match an endpoint in werkzeug's routing table
- url = local_url.partition('#')[0].split('?')
- path = url[0]
- query_string = url[1] if len(url) > 1 else None
- router = request.httprequest.app.get_db_router(request.db).bind('')
- # Force to check method to POST. Odoo uses methods : ['POST'] and ['GET', 'POST']
func = router.match(path, method='POST', query_args=query_string)[0]
- return (func.routing.get('website', False) and
- func.routing.get('multilang', func.routing['type'] == 'http'))
+ return is_multilang_func(func)
+ except werkzeug.exceptions.MethodNotAllowed:
+ func = router.match(path, method='GET', query_args=query_string)[0]
+ return is_multilang_func(func)
except werkzeug.exceptions.NotFound:
# Consider /static/ files as non-multilang
static_index = path.find('/static/', 1)
if static_index != -1 and static_index == path.find('/', 1):
return False
return True
- except Exception as e:
+ except Exception:
return False