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

Hi community,

I am looking at ways to determine the current company for a user in order to show only records for the current company for multi-company environments. I am wondering what is the purpose of this method:

self.env['res.company']._company_default_get()

Why do we need to go trough a method in res.company which calls a method in res.user.

Can't we directly call the method in res.user

self.env['res.users']._get_company()

Or even better can't we directly use:

self.env.user.company_id


What is the difference between the 3, which one is better to be used?

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

Hi, 

If you need to get the company of the currently logged in user - then the best way is to get directly self.env.user.company_id

Other two options will do the same, but via several static methods of corresponding classes.



อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
2
ต.ค. 23
6850
2
เม.ย. 23
6494
2
พ.ย. 22
7268
0
ก.ย. 21
3268
4
ส.ค. 20
8202