Skip to Content
Menu
This question has been flagged
3205 Zobrazenia

I have found this method in the calendar.py file of the calendar module. This method is does not allow the user to group using any criteria, because it removes from the result the 'group_count' value

#remove the count, since the value is not consistent with the result of the search when expand the group
            for groupname in groupby:
                if result.get(groupname + "_count"):
                    del result[groupname + "_count"]

I don't know why the are removing that field. This is the complete method

def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None, orderby=False, lazy=True):
        context = dict(context or {})

        if 'date' in groupby:
            raise osv.except_osv(_('Warning!'), _('Group by date is not supported, use the calendar view instead.'))
        virtual_id = context.get('virtual_id', True)
        context.update({'virtual_id': False})
        res = super(calendar_event, self).read_group(cr, uid, domain, fields, groupby, offset=offset, limit=limit, context=context, orderby=orderby, lazy=lazy)
        for result in res:
            #remove the count, since the value is not consistent with the result of the search when expand the group
            for groupname in groupby:
                if result.get(groupname + "_count"):
                    del result[groupname + "_count"]
            result.get('__context', {}).update({'virtual_id': virtual_id})
        return res

Avatar
Zrušiť