[FIX] fields: enable setting attribute group_operator to None

This commit is contained in:
Raphael Collet
2016-07-06 16:18:04 +02:00
parent cb30d0ef0e
commit 629e175501
2 changed files with 6 additions and 13 deletions
+5 -12
View File
@@ -1067,11 +1067,9 @@ class Boolean(Field):
class Integer(Field):
type = 'integer'
def _setup_regular_base(self, model):
super(Integer, self)._setup_regular_base(model)
if not self.group_operator:
self.group_operator = 'sum'
_slots = {
'group_operator': 'sum',
}
def convert_to_cache(self, value, record, validate=True):
if isinstance(value, dict):
@@ -1105,16 +1103,12 @@ class Float(Field):
type = 'float'
_slots = {
'_digits': None, # digits argument passed to class initializer
'group_operator': 'sum',
}
def __init__(self, string=Default, digits=Default, **kwargs):
super(Float, self).__init__(string=string, _digits=digits, **kwargs)
def _setup_regular_base(self, model):
super(Float, self)._setup_regular_base(model)
if not self.group_operator:
self.group_operator = 'sum'
@property
def digits(self):
if callable(self._digits):
@@ -1153,6 +1147,7 @@ class Monetary(Field):
type = 'monetary'
_slots = {
'currency_field': None,
'group_operator': 'sum',
}
def __init__(self, string=Default, currency_field=Default, **kwargs):
@@ -1168,8 +1163,6 @@ class Monetary(Field):
super(Monetary, self)._setup_regular_base(model)
if not self.currency_field:
self.currency_field = 'currency_id'
if not self.group_operator:
self.group_operator = 'sum'
def _setup_regular_full(self, model):
super(Monetary, self)._setup_regular_full(model)
+1 -1
View File
@@ -2137,7 +2137,7 @@ class BaseModel(object):
]
field_formatter = lambda f: (
self._fields[f].group_operator or 'sum',
self._fields[f].group_operator,
self._inherits_join_calc(self._table, f, query),
f,
)