تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
6845 أدوات العرض

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
يناير 24
12242
3
نوفمبر 23
17217
3
نوفمبر 24
24718
1
أبريل 23
6017
2
ديسمبر 22
6688