Skip to Content
Menú
This question has been flagged
4 Respostes
2501 Vistes

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

Avatar
Descartar
Best Answer

Hello, 

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

Thanks.

Avatar
Descartar
Best Answer

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!

Avatar
Descartar
Best Answer

hi 

try this,

request.env.user.company_id

Avatar
Descartar
Autor Best Answer

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


Avatar
Descartar
Related Posts Respostes Vistes Activitat
2
de juny 24
1883
3
de maig 24
1640
0
de juny 20
2625
1
de març 15
6431
1
d’oct. 24
966