Files
odoo_source/odoo/addons/test_read_group/models.py
T
Raphael Collet 580e78ad37 [IMP] models: enable field.group_expand on all types of fields (#16833)
The attribute `group_expand` allows to reorder and add empty groups to the
result of `read_group`.  Enable this feature for other fields than many2one
fields.
2017-05-05 16:37:11 +02:00

29 lines
916 B
Python

# -*- coding: utf-8 -*-
from odoo import fields, models
class GroupOnDate(models.Model):
_name = 'test_read_group.on_date'
date = fields.Date("Date")
value = fields.Integer("Value")
class BooleanAggregate(models.Model):
_name = 'test_read_group.aggregate.boolean'
_order = 'key DESC'
key = fields.Integer()
bool_and = fields.Boolean(default=False, group_operator='bool_and')
bool_or = fields.Boolean(default=False, group_operator='bool_or')
bool_array = fields.Boolean(default=False, group_operator='array_agg')
class GroupOnSelection(models.Model):
_name = 'test_read_group.on_selection'
state = fields.Selection([('a', "A"), ('b', "B")], group_expand='_expand_states')
value = fields.Integer()
def _expand_states(self, states, domain, order):
# return all possible states, in order
return [key for key, val in type(self).state.selection]