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.

0

How to apply domain filter on many2many field?

By
Stephen Raj
on 8/23/13, 9:16 AM 9,029 views

Hi,

       I've created many2many field. I would like to apply domain filter on the many2many field. The field reference is not storing in the master table but it's creating another table and storing the reference ids. May I know how to apply the domain filter on the many2many field with an example.

Thanks...

http://forum.openerp.com/forum/topic23503.html (the page refers to v6 but that works on v7 as well)

Prakash
on 8/23/13, 9:46 AM

I quote from the prakash link : " <field name="user_id" domain="[('id','in', [id for id in user_ids[0][2]]])]"/>

and you have to make the user_ids as a related field: 'user_ids': fields.related('group_id', 'user_ids', type="many2many", obj="res.users"),

and: the related field must be appear (at least invisible) in the form"

Xsias
on 8/23/13, 12:58 PM
1
el
On 12/6/13, 12:09 PM

An example to solve your issue :

in the model :

'functions_ids': fields.many2many('functions', 'function_partner_rel', 'partner_id',
                                      'function_id', 'Functions'),
'function_id': fields.many2one('functions', 'Position Occupied'),

In the view:

<field name="function_id" readonly="False" domain="[('id', 'in', parent.functions_ids[0][2])]"/>

@el, could you explain [0][2] in the view?

Daniel Blanco
on 4/5/15, 9:41 AM

... and who is parent?

Daniel Blanco
on 4/5/15, 10:20 AM

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: 8/23/13, 9:16 AM
Seen: 9029 times
Last updated: 3/16/15, 8:10 AM