[IMP]:Avg/sum for groupby
bzr revid: nch@tinyerp.com-20100308094036-hpvzsvlygup7s0e7
This commit is contained in:
parent
325bcd1c5b
commit
8856a549f7
|
@ -80,6 +80,7 @@ class _column(object):
|
|||
self.view_load = 0
|
||||
self.select = select
|
||||
self.selectable = True
|
||||
self.group_operator = args.get('group_operator', False)
|
||||
for a in args:
|
||||
if args[a]:
|
||||
setattr(self, a, args[a])
|
||||
|
@ -177,6 +178,7 @@ class float(_column):
|
|||
self.digits = digits
|
||||
self.digits_compute = digits_compute
|
||||
|
||||
|
||||
def digits_change(self, cr):
|
||||
if self.digits_compute:
|
||||
t = self.digits_compute(cr)
|
||||
|
|
|
@ -1007,7 +1007,7 @@ class orm_template(object):
|
|||
if fields and f not in fields:
|
||||
continue
|
||||
res[f] = {'type': self._columns[f]._type}
|
||||
for arg in ('string', 'readonly', 'states', 'size', 'required',
|
||||
for arg in ('string', 'readonly', 'states', 'size', 'required', 'group_operator',
|
||||
'change_default', 'translate', 'help', 'select', 'selectable'):
|
||||
if getattr(self._columns[f], arg):
|
||||
res[f][arg] = getattr(self._columns[f], arg)
|
||||
|
@ -1873,7 +1873,8 @@ class orm(orm_template):
|
|||
or (f in self._columns and getattr(self._columns[f], '_classic_write'))]
|
||||
for f in fields_pre:
|
||||
if f not in ['id','sequence']:
|
||||
flist += ',sum('+f+') as '+f
|
||||
operator = fget[f].get('group_operator','sum')
|
||||
flist += ','+operator+'('+f+') as '+f
|
||||
|
||||
cr.execute('select min(%s.id) as id,' % self._table + flist + ' from ' + ','.join(tables) + where_clause + ' group by '+ groupby + limit_str + offset_str, where_params)
|
||||
alldata = {}
|
||||
|
|
Loading…
Reference in New Issue