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 415 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
1

Hilar

--Hilar--
2220
| 5 3 8
Malappuram, India
--Hilar--
  Blog:-
        https://hilarlive.wordpress.com/
  StackOverflow:
        http://stackoverflow.com/users/7561347/burmese-pythis

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)

--Jérémy Kersten (jke)--
4550
| 3 3 5
Jodoigne, Belgium
--Jérémy Kersten (jke)--

Jérémy is a member of the core R&D team since september 2013. He developed several projects for OpenERP version 8 including the eCommerce, the Google Calendar synchronization and the new product variants/configurator. Now, he manages Odoo website and themes for saas.

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: 415 times
Last updated: 12/1/16, 3:23 AM