This commit is the 14th commit of a comprehensive refactor of our HTTP framework. See odoo/odoo#78857 for complete historic, discussions and rationnals. * `request.uid = x` => `request.update_env(user=x)`. * `request.context = x` => `request.update_env(context=x)`. * `request.context = dict(request.context, x=y)` => `request.update_context(x=y)`. * `request.cr = None` => `request.cr.close()`. * `http.mono_db()` => `request.db`. * `http.dispatch_rpc()` => `service.dispatch_rpc()`. * `@service.model.check` => `service.model.retrying()`. * `request.endpoint` => `env['ir.http']._match(request.httprequest.path)[0].endpoint`. * `request.routing_iteration `=> `removed`. * `request.jsonrequest` => `request.dispatcher.jsonrequest`. Note that `request.params` is now set much later in the process. If you are in a situation where you values from the query string or the http body you can use `request.get_http_params()`. Note that using the new `request.future_response`, it is possible to add headers and cookies on the response object before the response object is initialized. Please note that headers/cookies saved on the future response will NOT be injected in case of error. PR: odoo#78857 Task: 2571224
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()
|
|
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)
|