Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
4 Відповіді
2673 Переглядів

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

Аватар
Відмінити
Найкраща відповідь

Hello, 

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

Thanks.

Аватар
Відмінити
Найкраща відповідь

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!

Аватар
Відмінити
Найкраща відповідь

hi 

try this,

request.env.user.company_id

Аватар
Відмінити
Автор Найкраща відповідь

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


Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
2
черв. 24
1965
3
трав. 24
1721
0
черв. 20
2699
1
бер. 15
6499
1
жовт. 24
1036