Odoo Help

Welcome!

This community 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.

1

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

By
babu
on 6/19/14, 11:38 AM 1,329 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

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

0
babu
On 6/20/14, 3:04 AM

Thanks for post this answer Serpent Consulting services Pvt Ltd

0

Serpent Consulting Services Pvt. Ltd.

--Serpent Consulting Services Pvt. Ltd.--
4341
| 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

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.

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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