Merge pull request #28073 from akhilnarang/guess-fieldtype-total-row
chore(add_total_row): guess fieldtype from cell data type if not defined
This commit is contained in:
commit
fe3e22efc9
1 changed files with 5 additions and 0 deletions
|
|
@ -475,6 +475,11 @@ def add_total_row(result, columns, meta=None, is_tree=False, parent_field=None):
|
|||
if i >= len(row):
|
||||
continue
|
||||
cell = row.get(fieldname) if isinstance(row, dict) else row[i]
|
||||
if fieldtype is None:
|
||||
if isinstance(cell, int):
|
||||
fieldtype = "Int"
|
||||
elif isinstance(cell, float):
|
||||
fieldtype = "Float"
|
||||
if fieldtype in ["Currency", "Int", "Float", "Percent", "Duration"] and flt(cell):
|
||||
if not (is_tree and row.get(parent_field)):
|
||||
total_row[i] = flt(total_row[i]) + flt(cell)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue