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

I have 2 companies, am open the website in the second company, i am logged into the custom page that i create i need the id of the current company, that is 2 but when am call request.env.company or request.env.user.company i get the company id 1, but i am in the company 2 , how i solve this, in odoo 17

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

Hello, 

selected_companies = self.env['res.company'].browse(self._context.get('allowed_company_ids'))

Thanks.

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

You can use the company service in your js and then send it to the controller.

let activerCompany = company.activeCompanyIds

The controller always gives id 1. 


Hope this helps!

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

hi 

try this,

request.env.user.company_id

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

I need in controller, when am using the context in the controller i get an error , AttributeError: 'Request' object has no attribute '_context'


อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
2
มิ.ย. 24
1965
3
พ.ค. 24
1721
0
มิ.ย. 20
2700
1
มี.ค. 15
6499
1
ต.ค. 24
1037