Odoo Help

1

How to change and control the website.user_id value?

By
Pascal Tremblay
on 8/14/15, 12:47 PM 1,624 views

Hello all,

I can now control the request.uid in the method _auth_method_public of the class ir_http. It works well. I can change the current user according to the url.

Now, I'm searching the place to control and modify request.website.user_id. Where does it take his value? I want to control it too please.

Could you help please?


0

Hello Pascal,

You have to look inside module website => models => ir_http.py, following method is available and useful for you.

    def _dispatch(self):
first_pass = not hasattr(request, 'website')
...
...
if request.website_enabled:
try:
if func:
self._authenticate(func.routing['auth'])
else:
self._auth_method_public()
except Exception as e:
return self._handle_exception(e)
request.redirect = lambda url, code=302: werkzeug.utils.redirect(url_for(url), code)
request.website = request.registry['website'].get_current_website(request.cr, request.uid, context=request.context)
langs = [lg[0] for lg in request.website.get_languages()]
path = request.httprequest.path.split('/')
            ...
            ...
return super(ir_http, self)._dispatch()


Inside above method request.website is set with the browseble object of website model. And user_id is one of the fields of "website" model. So, you can access request.website.user_id. If you want to change then you can change it from the website setting menu.

I am sure that it will help a lot.

Thanks.

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: 8/14/15, 12:47 PM
Seen: 1624 times
Last updated: 8/17/15, 1:02 AM