This question has been flagged

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


Avatar
Discard

try with

self.env.company

self.env.company worked for me

Best Answer

Hi,

You can do this

company_id = self.env.company.id

Avatar
Discard
Best Answer
company = self.env.user.company_id
Avatar
Discard
Best Answer

Field company_id Get default company

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


Avatar
Discard
Best Answer

Hi, 

You can see following for this:

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

Hope it helps,

Thanks

Avatar
Discard
Best Answer

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
Discard
Best Answer

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

company = self.env.company_id


Avatar
Discard