Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
6943 Lượt xem

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.

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

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


Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
3
thg 1 24
12320
3
thg 11 23
17332
3
thg 11 24
24967
1
thg 4 23
6082
2
thg 12 22
6826