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

Hi Community,

I want to redirect the company(Internal User) to website home page and individual(internal user) to the backend. Now, Odoo redirects the internal user to backend. So, how to conditional redirect work?

ill find code related to it and try to coditional sign in, but didn't get expected result.

<template id="web.login" name="Login">
<t t-call="web.login_layout">
<form class="oe_login_form" role="form" t-attf-action="/web/login{{ '?debug' if debug else '' }}"
method="post" onsubmit="this.action = this.action + location.hash">
.
.
.
<div t-attf-class="clearfix oe_login_buttons text-center mb-1 {{'pt-2' if form_small else 'pt-3'}}">

<button type="submit" class="btn btn-primary btn-block">Sign in44</button>
<t t-if="debug">
<button type="submit" name="redirect" value="/web/become" class="btn btn-link btn-sm btn-block">
Log in as superuser
</button>
</t>
<div class="o_login_auth"/>
</div>
<t t-if="user_id.partner_id.company_type == 'company'">
<input type="hidden" name="redirect" value="/"/>
</t>
<t t-if="user_id.partner_id.company_type != 'company'">
<input type="hidden" name="redirect" t-att-value="redirect"/>
</t>
</form>
</t>
</template>

Thanks in advance.

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

Hi,

You can make necessary changes inside the web_login function. Here in this function you can see the redirection is done by checking the user group, so you can use the same function and do as per your need.

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

return http.redirect_with_hash(redirect)
return response

Thanks

Ảnh đại diện
Huỷ bỏ
Tác giả

Thanks Niyas. I'm making changes according to my condition and it's working.

Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 8 19
8785
2
thg 7 25
6231
0
thg 9 22
803
ODOO12 Redirect url Đã xử lý
2
thg 4 21
11874
1
thg 4 20
8086