Tuesday, July 26, 2011

Group Operator in OpenERP for Grouping

When defining search views, we may sometimes need to add "group_by" filters for showing the list view in groups. For example,







 The image shown above is from sale order. Here the list view grouping is done by user_id(salesman). Let focus on Demo User. Here four sale orders are created by the Demo user.

This is the extended view. Here the name written in bold is the group name. Now focus on the Untaxed Amount and Total and the value writen inside the red marker. The value shown inside the red marker are actually the sum of float or integer fields comes under the group. Here comes the use of group operator. The default value for group_operator is sum. Thats why we are getting the sum when grouping. To change the default value goto our python file, in the field definition add group_operator="avg" to get the average, group_operator="min" to get the minimum value from the group, group_operator="max" to get the maximum value from the group.
For example,

 Here I added group_operator="avg" in the untaxed amount. Now we have to verify it by grouping.
 Here the value shown inside the red marker is the average of that group. Now you can try the min and max by changing the group_operator value.

No comments:

Post a Comment