Hello,
How to test if the user is logged in in Odoo website ?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hello
if request.env.user == request.website.user_id:
Does this `request.website.user_id` returns the public user id ?
Safer to use the reference to the public user instead of hardcoding its id.
if request.env.user.id == request.env.ref('base.public_user').id:
return request.render('web.login', {})hi,
you can use request.session.uid or env.context.get('uid')
Hello,
This could be done with this code snippet inside a web controller: (Tested on Odoo 8)
public_user = http.request.env['res.users'].sudo().search([('id', '=', 3),('active', '=', False)]) # Public user default ID
if request.uid == public_user.id:
# The user is logged in
# Put your code for logged in user here
else:
# The user is not logged in
# Put your code for public users here
Regards,
Slim BHIRI
A really bad idea to do it...
Could you provide more explanation why it is a good idea and clarify your response please ? Because I haden't understood your reponse.
Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!
Zarejestruj się| Powiązane posty | Odpowiedzi | Widoki | Czynność | |
|---|---|---|---|---|
|
3
wrz 25
|
2605 | |||
|
Login Website
Rozwiązane
|
3
paź 25
|
149265 | ||
|
1
wrz 25
|
1996 | |||
|
Can't delete website
Rozwiązane
|
4
wrz 25
|
6895 | ||
|
2
sie 25
|
2100 |
1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.
reference: https://learnopenerp.blogspot.com/2017/10/how-to-check-login-user-group-in-odoo.html