Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
3 ตอบกลับ
9047 มุมมอง

Hi,


I am trying to print invoices into an excel sheet report. When a user has selected more than one company, I would like to print out all the records from these companies.
This is the code I am using to the active company:

active_company = self.env.company
This always returns one company even when more than one company is selected. How can I get a list of all the selected companies in odoo 13 to use that for filtering invoices

Thanks in advance for you assistance.


How can I list the currently selected companies

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

I figured a way to get a list of allowed companies in a multi-company setup

view_context = self.env.context

allowed_companies = view_context.get('allowed_company_ids', False)


The allowed companies should return a list/array of ids of the currently active companies. eg [1,2]

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi, 

You can see following for this:

https://youtu.be/GkNgc-fZO-I

Hope it helps,

Thanks

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi,

active_company = self.env.company

active_company value gives you the details of the company that you as a user have logged in.That is why its returning only one companies details.
You can get the list of companies from the many2many field that you use for selecting the companies.

Regards

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
Error message when duplicating company แก้ไขแล้ว
1
ธ.ค. 24
1209
4
ต.ค. 23
3510
how to delete a company? แก้ไขแล้ว
1
พ.ย. 23
13484
How to remove a existing company odoo 15 แก้ไขแล้ว
1
ต.ค. 22
3888
1
พ.ย. 20
9514