1
votes

I want to give domain on one2many field in xml and in domain I want to use field of one2many object.

For example: In Purchase Order Line of Purchase Order form view, I want to show those records whose product_qty is 2. "product_qty" is a field of purchase.order.line
This is my Purchase Order Line

<field name='order_line' domain="[('product_qty', '=', 2)]"

But its not working. I don't want to give domain in py file when field is define.

Can anyone know how to achieve this?

Thanks in advance

3

3 Answers

1
votes

product_qty is a non-searchable function field. Your domain therefore cannot work.

1
votes

You may try using dynamic function field. See the code in this answer by @AnomA.

0
votes

If you really need to achieve this you need to create a functional field of type boolean in which the function will return true if product_qty is 2.0, otherwise false. Then use this new field in the domain condition.<field name='order_line' domain="[('is_qty_2', '=', True)]" >