Odoo Help

0

How to test if the user is logged in in Odoo website ?

By
Slim BHIRI
on 11/30/16, 12:27 PM 661 views

Hello,

How to test if the user is logged in in Odoo website ?

0
Slim BHIRI
On 11/30/16, 2:53 PM

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...

Jérémy Kersten (jke)
on 12/1/16, 4:56 AM

Could you provide more explanation why it is a good idea and clarify your response please ? Because I haden't understood your reponse.

Nebras Solutions, Slim BHIRI
on 12/1/16, 5:40 PM

And please cancel your low rating for this reponse.

Nebras Solutions, Slim BHIRI
on 12/1/16, 5:41 PM
2
Hilar
On 12/1/16, 3:23 AM

hi,
you can use request.session.uid or env.context.get('uid')

1
Jérémy Kersten (jke)
On 11/30/16, 12:54 PM

Hello


if request.env.user == request.website.user_id:

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 11/30/16, 12:27 PM
Seen: 661 times
Last updated: 12/1/16, 3:23 AM