İçereği Atla
Menü
Bu soru işaretlendi
1 Cevapla
8643 Görünümler

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.

Avatar
Vazgeç
En İyi Yanı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

Avatar
Vazgeç
Üretici

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

İlgili Gönderiler Cevaplar Görünümler Aktivite
0
Ağu 19
8725
2
Tem 25
6142
0
Eyl 22
803
2
Nis 21
11836
1
Nis 20
8008