Odoo Help


How to get current website_id in controller of Odoo

Md. Tanzilul Hasan Khan
on 11/11/16, 4:20 AM 741 views

There are two websites in my odoo. One is localhost and another is

I have written following controller to get data from backend -

class website(http.Controller):
@http.route(['/action_get_event_menu_content'], type='json', auth="public")
def get_event_content(self):
website = request.env['website']
website_ids = website.sudo().search([])
value = website_ids.event_content
return value

Here website_id returns two ids (1,2)

How do I get current website_id in the search to filter the website and get the value?

@http.route(['/action_get_event_menu_content'], type='json', auth="public", website=True)
def get_event_content(self):
website_id = request.website.id

By this I can get current website id (which is loading). website=True sends the id.

Shameem Babu @ iWesabe
On 11/11/16, 4:50 AM


You can get current base url from your controller

from openerp import http
print http.request.env['ir.config_parameter'].get_param('web.base.url') # BASE URL 

You can identify which website is loaded

I am using odoo 10, so openerp will not work. But I have found a simpler way to do this.

Md. Tanzilul Hasan Khan
on 11/11/16, 5:24 AM

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.


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)


Asked: 11/11/16, 4:20 AM
Seen: 741 times
Last updated: 11/11/16, 5:26 AM