Thursday, March 1, 2012

Filters in one2many field - OpenERP

Last week I got into a situation that I really need to use filtering in tree view of one2many field. I have seen the use of filtering in search view, but not in tree views.
Example:
First of all this is just an example.
I have created a sale order. Here same product comes 2 or 3 times.
Sale Order view- Before adding filter



Then I was thinking for a solution... then came to find out that we can pass the filter condition in one2many fields too.

<field name="order_line" mode="tree,form" colspan="4" nolabel="1" widget="one2many_list" context="{'group_by':'name'}"> 

Then I was able to get the filter view.

Sale Order view after adding filter.
 The point is that you just need to provide context="{'group_by':'field_name'}"Here field_name is the name of the field in the tree view.

1 comment:

  1. This post is very helpful. Thank you so much! :)

    ReplyDelete