[IMP]:Avg for groupby
bzr revid: nch@tinyerp.com-20100210044200-mel3e6eqaqfxyz5q
This commit is contained in:
parent
4d7a51458b
commit
e86660db88
|
@ -1834,9 +1834,13 @@ class orm(orm_template):
|
|||
fields_pre = [f for f in float_int_fields if
|
||||
f == self.CONCURRENCY_CHECK_FIELD
|
||||
or (f in self._columns and getattr(self._columns[f], '_classic_write'))]
|
||||
avg_fields = context.get('avg',[])
|
||||
for f in fields_pre:
|
||||
if f not in ['id','sequence']:
|
||||
flist += ',sum('+f+') as '+f
|
||||
if f in avg_fields:
|
||||
flist += ',avg('+f+') as '+f
|
||||
else:
|
||||
flist += ',sum('+f+') as '+f
|
||||
cr.execute('select min(id) as id,'+flist+' from ' + self._table +qu1+' group by '+ groupby + limit_str + offset_str,qu2)
|
||||
alldata = {}
|
||||
for r in cr.dictfetchall():
|
||||
|
|
Loading…
Reference in New Issue