Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
8685 Visualizzazioni

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
Abbandona
Risposta migliore

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
Abbandona
Autore

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

Post correlati Risposte Visualizzazioni Attività
0
ago 19
8761
2
lug 25
6219
0
set 22
803
2
apr 21
11858
1
apr 20
8063