[SOLVED] odoo 8 remove sum of total in group by

Issue

This Content is from Stack Overflow. Question asked by Nur Faiz

I’m using odoo 8 and I wanto to remove sum of total in group by. Here is my .py

class report_sales_weekly(osv.osv):
_name = "report.sales.weekly"
_description = "report sales weekly"

_columns = {
            'div_target_monthly':fields.float('Div Target'),
            'div_achievement':fields.float('Div Achievement'),
            }
def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None, orderby=False):
    if 'div_target_monthly' in fields:
        fields.remove('div_target_monthly')
    return super(report_sales_weekly, self).read_group(cr, uid, domain, fields, groupby, offset, limit=limit, context=context, orderby=orderby)
report_sales_weekly()

I found this sricpt from https://www.odoo.com/forum/help-1/how-to-remove-sum-of-total-in-group-by-29666, but I get error when I make grouping in the list page

TypeError: read_group() got an unexpected keyword argument 'lazy'

Any help pleae? Thank you



Solution

You have two errors here: offset called without offset= and bad definition of the base read_group of Odoo 8.

Can you please try with this :

class report_sales_weekly(osv.osv):
    _name = "report.sales.weekly"
    _description = "report sales weekly"

    _columns = {
            'div_target_monthly':fields.float('Div Target'),
            'div_achievement':fields.float('Div Achievement'),
            }
    def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None, orderby=False, lazy=False):
        if 'div_target_monthly' in fields:
            fields.remove('div_target_monthly')
        return super(report_sales_weekly, self).read_group(cr, uid, domain, fields, groupby, offset=offset, limit=limit, context=context, orderby=orderby, lazy=lazy)
        # As stated in the comments, you can also not put offset=offset etc. but just the variables offset, limit, ... Thanks @Kenly
# Also, why this line ? 
# report_sales_weekly()

Keep me updated 🙂


This Question was asked in StackOverflow by Nur Faiz and Answered by Pierre Locus It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?