Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
3 ตอบกลับ
14275 มุมมอง

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

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([])
#TODO: FILTER CURRENT WEBSITE
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.

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Thanzil, 

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.

Related Posts ตอบกลับ มุมมอง กิจกรรม
0
ก.ค. 19
3143
1
ม.ค. 19
6303
3
พ.ค. 25
2623
0
ธ.ค. 23
2354
1
ก.ค. 23
2387