only generate subTotalsRows for totals fields with corresponding group field
This commit is contained in:
parent
2be1e6df6b
commit
8915a22bda
3 changed files with 19 additions and 17 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -2,3 +2,5 @@
|
||||||
ajax/dojo/*
|
ajax/dojo/*
|
||||||
*.project
|
*.project
|
||||||
*.pydevproject
|
*.pydevproject
|
||||||
|
*.sublime-project
|
||||||
|
*.sublime-workspace
|
||||||
|
|
|
@ -186,7 +186,7 @@ class LeafQueryCriteria(BaseQueryCriteria, Element):
|
||||||
if comparisonValue in (None, '',):
|
if comparisonValue in (None, '',):
|
||||||
return True
|
return True
|
||||||
value = self.field.getSelectValue(row)
|
value = self.field.getSelectValue(row)
|
||||||
if (self.field.fieldType == 'number' and
|
if (self.field.fieldType == 'number' and
|
||||||
isinstance(comparisonValue, basestring)):
|
isinstance(comparisonValue, basestring)):
|
||||||
comparisonValue = int(comparisonValue)
|
comparisonValue = int(comparisonValue)
|
||||||
op = operators.get(self.operator)
|
op = operators.get(self.operator)
|
||||||
|
|
32
composer/report/result.py
Normal file → Executable file
32
composer/report/result.py
Normal file → Executable file
|
@ -61,7 +61,7 @@ class Row(BaseRow):
|
||||||
@Lazy
|
@Lazy
|
||||||
def displayedColumns(self):
|
def displayedColumns(self):
|
||||||
return self.parent.context.getActiveOutputFields()
|
return self.parent.context.getActiveOutputFields()
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def allColumns(self):
|
def allColumns(self):
|
||||||
return self.parent.context.getAllFields()
|
return self.parent.context.getAllFields()
|
||||||
|
@ -121,8 +121,10 @@ class ResultSet(object):
|
||||||
headerColumn.cssClass = c.cssClass
|
headerColumn.cssClass = c.cssClass
|
||||||
headerRow.headerColumns.append(headerColumn)
|
headerRow.headerColumns.append(headerColumn)
|
||||||
return headerRow
|
return headerRow
|
||||||
|
|
||||||
def getSubTotalsRow(self, gf, row, columns, values):
|
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 = SubTotalsRow(None, self)
|
||||||
subTotalsRow.cssClass = 'subTotalsRow'
|
subTotalsRow.cssClass = 'subTotalsRow'
|
||||||
for idx, c in enumerate(columns):
|
for idx, c in enumerate(columns):
|
||||||
|
@ -131,8 +133,10 @@ class ResultSet(object):
|
||||||
if gf.totalsDescription is None:
|
if gf.totalsDescription is None:
|
||||||
subTotalsRow.data[gf.output] = u'SUMME: ' + gf.getDisplayValue(row)
|
subTotalsRow.data[gf.output] = u'SUMME: ' + gf.getDisplayValue(row)
|
||||||
else:
|
else:
|
||||||
subTotalsRow.data[gf.totalsDescription.output] = u'SUMME: ' + \
|
v = gf.totalsDescription.getDisplayValue(row)
|
||||||
gf.totalsDescription.getDisplayValue(row)
|
if v is None:
|
||||||
|
v = u''
|
||||||
|
subTotalsRow.data[gf.totalsDescription.output] = u'SUMME: ' + v
|
||||||
return subTotalsRow
|
return subTotalsRow
|
||||||
|
|
||||||
def getResult(self):
|
def getResult(self):
|
||||||
|
@ -158,12 +162,10 @@ class ResultSet(object):
|
||||||
groupValues[idx] = value
|
groupValues[idx] = value
|
||||||
headerRows.append(self.getHeaderRow(row, (f,) + f.outputWith))
|
headerRows.append(self.getHeaderRow(row, (f,) + f.outputWith))
|
||||||
if lastRow is not None and f.getDisplayValue(lastRow):
|
if lastRow is not None and f.getDisplayValue(lastRow):
|
||||||
subTotalsRows.append(
|
subTr = self.getSubTotalsRow(f, lastRow,
|
||||||
self.getSubTotalsRow(f,
|
self.subTotalsColumns[idx], subTotals[idx])
|
||||||
lastRow,
|
if subTr is not None:
|
||||||
self.subTotalsColumns[idx],
|
subTotalsRows.append(subTr)
|
||||||
subTotals[idx]
|
|
||||||
))
|
|
||||||
subTotals[idx] = [0.0 for f in self.subTotalsColumns[idx]]
|
subTotals[idx] = [0.0 for f in self.subTotalsColumns[idx]]
|
||||||
for subTotalsRow in reversed(subTotalsRows):
|
for subTotalsRow in reversed(subTotalsRows):
|
||||||
res.append(subTotalsRow)
|
res.append(subTotalsRow)
|
||||||
|
@ -178,12 +180,10 @@ class ResultSet(object):
|
||||||
subTotalsRows = []
|
subTotalsRows = []
|
||||||
for idx, f in enumerate(self.groupColumns):
|
for idx, f in enumerate(self.groupColumns):
|
||||||
if f.getDisplayValue(lastRow):
|
if f.getDisplayValue(lastRow):
|
||||||
subTotalsRows.append(
|
subTr = self.getSubTotalsRow(f, lastRow,
|
||||||
self.getSubTotalsRow(f,
|
self.subTotalsColumns[idx], subTotals[idx])
|
||||||
lastRow,
|
if subTr is not None:
|
||||||
self.subTotalsColumns[idx],
|
subTotalsRows.append(subTr)
|
||||||
subTotals[idx]
|
|
||||||
))
|
|
||||||
for subTotalsRow in reversed(subTotalsRows):
|
for subTotalsRow in reversed(subTotalsRows):
|
||||||
res.append(subTotalsRow)
|
res.append(subTotalsRow)
|
||||||
result = res
|
result = res
|
||||||
|
|
Loading…
Add table
Reference in a new issue