Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
4 Antworten
2659 Ansichten

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
Verwerfen
Beste Antwort

Hello, 

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

Thanks.

Avatar
Verwerfen
Beste Antwort

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
Verwerfen
Beste Antwort

hi 

try this,

request.env.user.company_id

Avatar
Verwerfen
Autor Beste Antwort

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


Avatar
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
2
Juni 24
1962
3
Mai 24
1717
0
Juni 20
2689
1
März 15
6498
1
Okt. 24
1029