跳至内容
菜单
此问题已终结
4 回复
2675 查看

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'


形象
丢弃
相关帖文 回复 查看 活动
2
6月 24
1965
3
5月 24
1721
0
6月 20
2699
1
3月 15
6499
1
10月 24
1036