Odoo Help

Welcome!

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

0

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

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

Hello,

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

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

Hilar AK

--Hilar AK--
778
| 4 1 7
Italy
--Hilar AK--


Hilar AK
On 12/1/16, 3:23 AM

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

0

Jérémy Kersten (jke)

--Jérémy Kersten (jke)--
2983
| 3 2 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:

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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