This question has been flagged
5 Replies
28736 Views

In OpenERP 7 List view time data added using the below code:-

'in_time' : fields.float('In Time'),

<field name="intake_time" widget="float_time"/>

In List view selected "Group by " any fields Header shows Total In time Value

How to remove Total In time value ? [in xml file not added sum keyword but group by still shows sum time ]

Avatar
Discard
Best Answer

Hi,

Probably a bit late!

You could override the read_group method like this on you model:

    def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None, orderby=False):
        if 'intake_time' in fields:
            fields.remove('intake_time')
        return super(MyClassName, self).read_group(cr, uid, domain, fields, groupby, offset, limit=limit, context=context, orderby=orderby)

Avatar
Discard

I let a 'c' on the if condition, unfortunately, I haven't enough karma to edit my own post!...

I completely agree with this method, I tried it and it works! Thank you.

Thanks for this tip. It still work in Odoo 8.0

By the way I fixed the extra 'c'

Not too late at all. Thanks. Still works on Odoo 9.0.

Ok after struggling with another issue on the pivot view, I figured out this hack is causing problem... seems like the pivot view is confused on the groups and javascript is crashing when selecting measures or "Expand all". I think the js code can be fixed to fully support the hack here and I will fill a ticket at Odoo.

There is no issue with the pivot finally!!! Problem is that last line should be:

return super(ReportDetailInvoice, self).read_group(cr, uid, domain, fields, groupby, offset, limit, context, orderby, lazy).

tks, it works, but I must change the first and last line

first line : ... , lazy=True) :

last line : ... , lazy=lazy)

Only for your information, this solution does in Odoo 15 exactly the opposite. It keeps the sum value in the header from the grouped element and removes the value of the field from all child records of the group.

For Odoo 15 is the correct way to add the option group_operator=False to the python declaration of the field.

Best Answer

If the field has the tag sum in the tree view, when you use the group by you have the sum of all records. Remove the sum tag from view so you has'nt the sum when use group by

Avatar
Discard
Best Answer

For Odoo 15 is the correct way to add the option -> group_operator=False to the python declaration of the field. This removes the sum value in the header from a grouped element for the field.

Avatar
Discard
Best Answer

Hello Prakash,

By default OpenERP Will consider 'SUM' as group operator . So you wan't be able to remove this behavior easily by any sort of configuration or xml code. For this you need to make changes in the orm.py in def read_group method and comment out the code that adds the default 'SUM' to integer and float fields at line 2664.

Hope this helps !

Avatar
Discard
Author

Thanks for reply i will try

Author Best Answer

The default Float field value for group_operator shows sum of value

Reference link http://www.zbeanztech.com/blog/group-operator-openerp-grouping

Currently "Group by" Field values able to change to min, max, avg

But unable to remove group by value

i applied group_operator = None or group_operator = False but its still shows sum of total. How to group_by remove sum or set to value None

Any update?..

Avatar
Discard