dccdany
dccdany

Reputation: 836

Get the current company without ids or uid in Odoo / OpenERP

I need to create a function that takes a default value, this value is distinct for each company.

Thing is that I can't use the uid because the user can do this in any company, and I have no object to ask ids for because its for a default field.

Is there any way to get the current company without using ids or the uid ?

Thanks in advance.

Upvotes: 1

Views: 6254

Answers (2)

Slim
Slim

Reputation: 306

Yes, you can do that thourgh this code :

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

Upvotes: 0

Adrian Merrall
Adrian Merrall

Reputation: 2499

Not sure I completely understand your question.

A user may be able to do something in any company depending on their list of allowed companies, but a user can only ever do something in one company at a time.

Any user can change their current company to one of the companies they are allowed but when they do this, the company_id on the user record is changed so if you browse res.users using the UID you will always get the current company of the user.

The only exception I can think of is if you give the user a list of companies they are allowed to see and give them a button or check box to do something on that company. In this case, your screen will need to be backed by a model and you can check on there so see which company they chose, either by browsing to see which record has the checkbox set, or if you put a button or action on a tree view, the method will get the IDs of the records selected.

Upvotes: 1

Related Questions