Odoo Help


How to create an access rule to compare ids from many2many Field?

on 6/19/14, 11:38 AM 2,234 views

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

Anton Chepurov
On 10/22/14, 3:35 AM

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])]

On 6/20/14, 3:04 AM

Thanks for post this answer Serpent Consulting services Pvt Ltd


Serpent Consulting Services Pvt. Ltd.

--Serpent Consulting Services Pvt. Ltd.--
| 6 6 8
Gandhinagar, India
--Serpent Consulting Services Pvt. Ltd.--

Serpent Consulting Services Pvt. Ltd. Your Odoo/OpenERP Solution, just an email away!

Serpent Consulting Services Pvt. Ltd.
On 6/19/14, 12:00 PM


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.


=> 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.


About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 6/19/14, 11:38 AM
Seen: 2234 times
Last updated: 5/21/16, 9:52 AM