Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
4 Vastaukset
2682 Näkymät

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
Hylkää
Paras vastaus

Hello, 

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

Thanks.

Avatar
Hylkää
Paras vastaus

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
Hylkää
Paras vastaus

hi 

try this,

request.env.user.company_id

Avatar
Hylkää
Tekijä Paras vastaus

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


Avatar
Hylkää
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
2
kesäk. 24
1968
3
toukok. 24
1723
0
kesäk. 20
2702
1
maalisk. 15
6499
1
lokak. 24
1037