only generate subTotalsRows for totals fields with corresponding group field

This commit is contained in:
hplattner 2013-08-07 11:02:50 +02:00
parent 2be1e6df6b
commit 8915a22bda
3 changed files with 19 additions and 17 deletions

2
.gitignore vendored
View file

@ -2,3 +2,5 @@
ajax/dojo/*
*.project
*.pydevproject
*.sublime-project
*.sublime-workspace

View file

@ -186,7 +186,7 @@ class LeafQueryCriteria(BaseQueryCriteria, Element):
if comparisonValue in (None, '',):
return True
value = self.field.getSelectValue(row)
if (self.field.fieldType == 'number' and
if (self.field.fieldType == 'number' and
isinstance(comparisonValue, basestring)):
comparisonValue = int(comparisonValue)
op = operators.get(self.operator)

32
composer/report/result.py Normal file → Executable file
View file

@ -61,7 +61,7 @@ class Row(BaseRow):
@Lazy
def displayedColumns(self):
return self.parent.context.getActiveOutputFields()
@Lazy
def allColumns(self):
return self.parent.context.getAllFields()
@ -121,8 +121,10 @@ class ResultSet(object):
headerColumn.cssClass = c.cssClass
headerRow.headerColumns.append(headerColumn)
return headerRow
def getSubTotalsRow(self, gf, row, columns, values):
if not gf.name in [','.join(c.totals) for c in columns]:
return None
subTotalsRow = SubTotalsRow(None, self)
subTotalsRow.cssClass = 'subTotalsRow'
for idx, c in enumerate(columns):
@ -131,8 +133,10 @@ class ResultSet(object):
if gf.totalsDescription is None:
subTotalsRow.data[gf.output] = u'SUMME: ' + gf.getDisplayValue(row)
else:
subTotalsRow.data[gf.totalsDescription.output] = u'SUMME: ' + \
gf.totalsDescription.getDisplayValue(row)
v = gf.totalsDescription.getDisplayValue(row)
if v is None:
v = u''
subTotalsRow.data[gf.totalsDescription.output] = u'SUMME: ' + v
return subTotalsRow
def getResult(self):
@ -158,12 +162,10 @@ class ResultSet(object):
groupValues[idx] = value
headerRows.append(self.getHeaderRow(row, (f,) + f.outputWith))
if lastRow is not None and f.getDisplayValue(lastRow):
subTotalsRows.append(
self.getSubTotalsRow(f,
lastRow,
self.subTotalsColumns[idx],
subTotals[idx]
))
subTr = self.getSubTotalsRow(f, lastRow,
self.subTotalsColumns[idx], subTotals[idx])
if subTr is not None:
subTotalsRows.append(subTr)
subTotals[idx] = [0.0 for f in self.subTotalsColumns[idx]]
for subTotalsRow in reversed(subTotalsRows):
res.append(subTotalsRow)
@ -178,12 +180,10 @@ class ResultSet(object):
subTotalsRows = []
for idx, f in enumerate(self.groupColumns):
if f.getDisplayValue(lastRow):
subTotalsRows.append(
self.getSubTotalsRow(f,
lastRow,
self.subTotalsColumns[idx],
subTotals[idx]
))
subTr = self.getSubTotalsRow(f, lastRow,
self.subTotalsColumns[idx], subTotals[idx])
if subTr is not None:
subTotalsRows.append(subTr)
for subTotalsRow in reversed(subTotalsRows):
res.append(subTotalsRow)
result = res