如何在Odoo控制器中获得当前的website_id



在我的网站模型中有两个网站id -

id 1有localhsot网站和

id 2有0.0.0.0网站

我写了以下控制器从后端到前端获取数据-

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

在这个控制器中,website_ids = (1,2)

返回两个id

我如何得到当前的网站id,并把它在搜索得到的值?

尝试'request.website'。它应该给你当前的网站。

最新更新