Ayuda

0

How to get current company_id in multi company in odoo 13

Hello Odooers,

I have enabled multi company mode, so i can be able to switch to any company which i have access.

But i am fetching current company_id in python and it's giving me default company. Also i have noticed few points:

- I can be able to select more than one company to switch (which is not possible in odoo 12)

- Whenever i switch to any company then my active company_id is not changing.

Can anyone suggest me how to get current company_id in multicompany in odoo13


2Comentarios
Avatar
Descartar
Avatar
subbarao
-

try with

self.env.company

Avatar
Jose Gpe Osuna
-

self.env.company worked for me

5Respuestas
8
Avatar
MING
Mejor respuesta

Hi,

You can do this

company_id = self.env.company.id

Avatar
Descartar
5
Avatar
Muhammad Anees
Mejor respuesta
company = self.env.user.company_id
Avatar
Descartar
0
Avatar
Amilcar Júnior
Mejor respuesta

Field company_id Get default company

company_id = fields.Many2one('res.company', string='Company',default=lambda self: self.env.company)


Avatar
Descartar
0
Avatar
Oscar del Rio
Mejor respuesta

I am having the same problem, no matter which of the suggested variables I use, I get the default company regardless of which one I use. I am trying to use it in an inherited view of Web Layout... I don't know if it has anything to do? I am suspecting that maybe it is because that modules load before the rest?

@Daniel Jove. Any solution up to now?

Avatar
Descartar
0
Avatar
Daniel Jove
Mejor respuesta

for me it give me the prefered company, not the current company 

company = self.env.company_id


Avatar
Descartar