跳至內容
選單
此問題已被標幟
1 回覆
6929 瀏覽次數

Hello All,

I am working on Odoo12. when I log in for odoo then it redirects me on the same login page and all login options available for me. So, the problem is related to redirect. I have tested the code and got that request.params['login_success'] show 'false' value in print. My python code is below.

    @http.route(website=True, auth="public")
def web_login(self, redirect=None, *args, **kw):
response = super(CustomAuthSignupHome, self).web_login(redirect=redirect, *args, **kw)
print('Loginnn', request.params['login_success'])
if not redirect and request.params['login_success']:
user = request.env['res.users'].browse(request.uid)
if user.has_group('base.group_user'):
if user.partner_id.company_type == 'company':
redirect = '/dashboard'
else:
redirect = b'/web?' + request.httprequest.query_string
return http.redirect_with_hash(redirect)
return response

So, anyone can suggest the solution for this problem. 

Thanks in advance.

頭像
捨棄
作者 最佳答案

Problem solved. missed else condition for redirection


@http.route(website=True, auth="public")
def web_login(self, redirect=None, *args, **kw):
response = super(CustomAuthSignupHome, self).web_login(redirect=redirect, *args, **kw)
if not redirect and request.params['login_success']:
user = request.env['res.users'].browse(request.uid)
if user.has_group('base.group_user'):
if user.partner_id.company_type == 'company':
redirect = '/dashboard'
else:
redirect = b'/web?' + request.httprequest.query_string
else:
redirect = '/my/account'
return http.redirect_with_hash(redirect)
return response


頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
3
1月 24
12314
3
11月 23
17311
3
11月 24
24919
1
4月 23
6063
2
12月 22
6799