Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
4 Ответы
2706 Представления

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
1974
3
мая 24
1728
0
июн. 20
2727
1
мар. 15
6519
1
окт. 24
1071