This branch adds request.redirect on all requests. In case of a front end request, we do an url_for to the location. We removed redirect_with_hash that was only for retro compatibility local_redirect has been renamed to redirect_query, and param keep_hash has been removed and moved. Default code for redirect is 303 now instead of 302. Now redirect and redirect_query make local redirect by default, you need to pass local=False to make external redirect. All werkeug.utils.redirect has been replaced by request.redirect. Http.redirect now use an http.Response type, and it become easy to add an override like 'set_cookies' e.g. Dispatch of a website.page return an http.response too, so we first need to check if it is a cached version before to check if it is an Odoo Response. Migrate your code: http.redirect -> request.redirect(location, code, local) http.local_redirect -> request.redirect_query(location, query, code, local) http.redirect_with_hash -> request.redirect Courtesy of odony for help and review ;) closes odoo/odoo#72599 Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
27 lines
1.1 KiB
Python
27 lines
1.1 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo import http
|
|
from odoo.addons.web.controllers import main
|
|
from odoo.http import request
|
|
|
|
|
|
class Home(main.Home):
|
|
|
|
@http.route()
|
|
def index(self, *args, **kw):
|
|
if request.session.uid and not request.env['res.users'].sudo().browse(request.session.uid).has_group('base.group_user'):
|
|
return request.redirect_query('/my', query=request.params)
|
|
return super(Home, self).index(*args, **kw)
|
|
|
|
def _login_redirect(self, uid, redirect=None):
|
|
if not redirect and not request.env['res.users'].sudo().browse(uid).has_group('base.group_user'):
|
|
redirect = '/my'
|
|
return super(Home, self)._login_redirect(uid, redirect=redirect)
|
|
|
|
@http.route('/web', type='http', auth="none")
|
|
def web_client(self, s_action=None, **kw):
|
|
if request.session.uid and not request.env['res.users'].sudo().browse(request.session.uid).has_group('base.group_user'):
|
|
return request.redirect_query('/my', query=request.params)
|
|
return super(Home, self).web_client(s_action, **kw)
|