Search code examples
controllerodooodoo-website

How to get current website_id in controller of Odoo


There are two website ids in my website model -

id 1 has localhsot website and

id 2 has 0.0.0.0 website

I have written following controller to get data from backend to frontend -

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([])
    #TODO: FILTER CURRENT WEBSITE
    value = website_ids.event_content
    return value

In this controller two ids get returned in website_ids = (1,2)

How do I get the current website id and put that in the search to get the value?


Solution

  • Try 'request.website'. It should give you the current website.