Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
4 Odpowiedzi
2635 Widoki

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

Awatar
Odrzuć
Najlepsza odpowiedź

Hello, 

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

Thanks.

Awatar
Odrzuć
Najlepsza odpowiedź

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!

Awatar
Odrzuć
Najlepsza odpowiedź

hi 

try this,

request.env.user.company_id

Awatar
Odrzuć
Autor Najlepsza odpowiedź

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


Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
2
cze 24
1948
3
maj 24
1706
0
cze 20
2684
1
mar 15
6488
1
paź 24
1022