Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
33610 มุมมอง

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)

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"

คำตอบที่ดีที่สุด

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?

... and who is parent?

คำตอบที่ดีที่สุด

Hello Stephen 

you can use below search filter

อวตาร
ละทิ้ง

<field name="category_id" string="Tag" filter_domain="[('category_id', 'child_of', self)]"/>

Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ก.พ. 24
2130
0
ก.ค. 24
3169
0
ก.ค. 22
60
1
ก.ค. 22
3074
3
พ.ค. 21
4092