Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
13061 Vistas

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?

Avatar
Descartar
Mejor respuesta

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.



Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
2
oct 23
6866
2
abr 23
6566
2
nov 22
7288
0
sept 21
3292
4
ago 20
8222