[FIX] website: search a matching route with http method POST

When url_for was looking for a route which match, it was only looking for GET route.
So routes which were restricted to be used only with a POST method, were never found.

The result was that urls in website for route post (form in most cases) was never prefixed with the lang.
So the request.lang was always the default lang from website...

If you was creating a sale order (in ecommerce), the lang used in sale order was wrong and the description not in the current lang.
This commit is contained in:
Jeremy Kersten 2015-01-15 23:16:33 +01:00
parent c2344ad8eb
commit 9d89b179c4
1 changed files with 2 additions and 1 deletions

View File

@ -77,7 +77,8 @@ def is_multilang_url(local_url, langs=None):
path = url[0]
query_string = url[1] if len(url) > 1 else None
router = request.httprequest.app.get_db_router(request.db).bind('')
func = router.match(path, query_args=query_string)[0]
# 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', True)
except Exception:
return False