تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
4 الردود
2669 أدوات العرض

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
يونيو 24
1963
3
مايو 24
1720
0
يونيو 20
2697
1
مارس 15
6499
1
أكتوبر 24
1035