From db23690db3655b06da71a33a0de29dbab6c7f1a8 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Wed, 8 Apr 2015 18:31:43 +0200 Subject: [PATCH] [FIX] website: json are not multilang by default. This avoid useless redirection. --- addons/website/controllers/main.py | 10 ++++------ addons/website/models/ir_http.py | 5 ++++- addons/website/models/website.py | 3 ++- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/addons/website/controllers/main.py b/addons/website/controllers/main.py index f1f4f6d9992..34945e4b987 100644 --- a/addons/website/controllers/main.py +++ b/addons/website/controllers/main.py @@ -237,15 +237,13 @@ class Website(openerp.addons.web.controllers.main.Home): return request.registry["ir.ui.view"].customize_template_get( request.cr, request.uid, xml_id, full=full, context=request.context) - - @http.route('/website/get_view_translations', type='json', auth='public', website=True, multilang=False) + @http.route('/website/get_view_translations', type='json', auth='public', website=True) def get_view_translations(self, xml_id, lang=None): lang = lang or request.context.get('lang') return request.registry["ir.ui.view"].get_view_translations( request.cr, request.uid, xml_id, lang=lang, context=request.context) - - @http.route('/website/set_translations', type='json', auth='public', website=True, multilang=False) + @http.route('/website/set_translations', type='json', auth='public', website=True) def set_translations(self, data, lang): irt = request.registry.get('ir.translation') for view_id, trans in data.items(): @@ -283,7 +281,7 @@ class Website(openerp.addons.web.controllers.main.Home): irt.create(request.cr, request.uid, new_trans) return True - @http.route('/website/translations', type='json', auth="public", website=True, multilang=False) + @http.route('/website/translations', type='json', auth="public", website=True) def get_website_translations(self, lang): module_obj = request.registry['ir.module.module'] module_ids = module_obj.search(request.cr, request.uid, [('name', 'ilike', 'website'), ('state', '=', 'installed')], context=request.context) @@ -336,7 +334,7 @@ class Website(openerp.addons.web.controllers.main.Home): window.parent['%s'](%s, %s); """ % (func, json.dumps(website_url), json.dumps(message)) - @http.route(['/website/publish'], type='json', auth="public", website=True, multilang=False) + @http.route(['/website/publish'], type='json', auth="public", website=True) def publish(self, id, object): _id = int(id) _object = request.registry[object] diff --git a/addons/website/models/ir_http.py b/addons/website/models/ir_http.py index 3f1ec566a2f..e19edb60b2f 100644 --- a/addons/website/models/ir_http.py +++ b/addons/website/models/ir_http.py @@ -64,7 +64,10 @@ class ir_http(orm.AbstractModel): # in all cases, website processes them request.website_enabled = True - request.website_multilang = request.website_enabled and func and func.routing.get('multilang', True) + request.website_multilang = ( + request.website_enabled and + func and func.routing.get('multilang', func.routing['type'] == 'http') + ) if 'geoip' not in request.session: record = {} diff --git a/addons/website/models/website.py b/addons/website/models/website.py index 826a77022da..dfd61a707df 100644 --- a/addons/website/models/website.py +++ b/addons/website/models/website.py @@ -79,7 +79,8 @@ def is_multilang_url(local_url, langs=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', True) + return (func.routing.get('website', False) and + func.routing.get('multilang', func.routing['type'] == 'http')) except Exception: return False