콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
4 답글
2702 화면

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'


아바타
취소
관련 게시물 답글 화면 활동
2
6월 24
1972
3
5월 24
1727
0
6월 20
2724
1
3월 15
6516
1
10월 24
1062