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:
Akhil Narang 2024-10-11 11:35:04 +05:30 committed by GitHub
commit fe3e22efc9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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)