[FIX] orm, fields: read_group on monetary fields now correctly makes the sum instead of ignoring them
This commit is contained in:
+6
-1
@@ -1098,15 +1098,20 @@ class Monetary(Field):
|
||||
type = 'monetary'
|
||||
_slots = {
|
||||
'currency_field': None,
|
||||
'group_operator': None, # operator for aggregating values
|
||||
}
|
||||
|
||||
def __init__(self, string=None, currency_field=None, **kwargs):
|
||||
super(Monetary, self).__init__(string=string, currency_field=currency_field, **kwargs)
|
||||
|
||||
_column_currency_field = property(attrgetter('currency_field'))
|
||||
_related_currency_field = property(attrgetter('currency_field'))
|
||||
_related_group_operator = property(attrgetter('group_operator'))
|
||||
|
||||
_description_currency_field = property(attrgetter('currency_field'))
|
||||
|
||||
_column_currency_field = property(attrgetter('currency_field'))
|
||||
_column_group_operator = property(attrgetter('group_operator'))
|
||||
|
||||
def _setup_regular_base(self, model):
|
||||
super(Monetary, self)._setup_regular_base(model)
|
||||
if not self.currency_field:
|
||||
|
||||
+1
-1
@@ -2069,7 +2069,7 @@ class BaseModel(object):
|
||||
if f not in ('id', 'sequence')
|
||||
if f not in groupby_fields
|
||||
if f in self._fields
|
||||
if self._fields[f].type in ('integer', 'float')
|
||||
if self._fields[f].type in ('integer', 'float', 'monetary')
|
||||
if getattr(self._fields[f].base_field.column, '_classic_write', False)
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user