Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
4 Răspunsuri
2526 Vizualizări

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

Imagine profil
Abandonează
Cel mai bun răspuns

Hello, 

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

Thanks.

Imagine profil
Abandonează
Cel mai bun răspuns

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!

Imagine profil
Abandonează
Cel mai bun răspuns

hi 

try this,

request.env.user.company_id

Imagine profil
Abandonează
Autor Cel mai bun răspuns

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


Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
2
iun. 24
1895
3
mai 24
1652
0
iun. 20
2640
1
mar. 15
6444
1
oct. 24
971