Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
6950 มุมมอง

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


อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
Odoo 12 shows a blank page after login? แก้ไขแล้ว
3
ม.ค. 24
12322
How to track One2many field in Odoo12? แก้ไขแล้ว
3
พ.ย. 23
17333
Error: Couldn't load module web แก้ไขแล้ว
3
พ.ย. 24
24974
How I get the current ID of a record ? แก้ไขแล้ว
1
เม.ย. 23
6086
2
ธ.ค. 22
6831