Hi to All,
I have to create an access rule in which I have to compare the company_id with Allowed Companies(many2many field company_ids in users screen).
Thanks in Advance
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hi to All,
I have to create an access rule in which I have to compare the company_id with Allowed Companies(many2many field company_ids in users screen).
Thanks in Advance
Hi,
I have same case for Odoo V12. Following code works for me.
['|', ('x_users', '=', False),('x_users', 'in', [user.id])]
x_users is my many2many field.
Here's another one:
[('company_id', 'in', user.read(['company_ids'])[0]['company_ids'])]
and yet another one (possibly slower, but shorter and nicer to read):
[('company_id', 'in', [c.id for c in user.company_ids])]
Madhubabu,
In OpenERP, for major of the existing models the record rule exists where there is a field company_id or user_id.
If you model is custom, you should consider the following record rule.
['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]
=> Means the user will see the records of your model where he is the user of the main company or its children companies.
Or, foryour own record, its company_ids field for 'Allowed companies'. So [('company_id','in',user.company_ids)]
Hope this helps.
Thanks.
Thanks for post this answer Serpent Consulting services Pvt Ltd
Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!
Aanmelden