fix(reportview): support dict. when parsing fields

QB generates a dict. so added support for that when exporting into Excel/CSV
This commit is contained in:
AarDG10 2026-04-14 12:48:31 +05:30
parent 2ac1998000
commit e334e327fb

View file

@ -520,8 +520,11 @@ def get_field_info(fields, doctype):
except ValueError: except ValueError:
# handles aggregate functions # handles aggregate functions
parenttype = doctype parenttype = doctype
fieldname = key.split("(", 1)[0] if isinstance(key, dict):
fieldname = fieldname[0].upper() + fieldname[1:] fieldname = next(k for k in key if k != "as")
else:
fieldname = key.split("(", 1)[0]
fieldname = fieldname.capitalize()
parenttype = parenttype or doctype parenttype = parenttype or doctype
@ -580,8 +583,11 @@ def handle_duration_fieldtype_values(doctype, data, fields):
return data return data
def parse_field(field: str) -> tuple[str | None, str]: def parse_field(field: str | dict) -> tuple[str | None, str]:
"""Parse a field into parenttype and fieldname.""" """Parse a field into parenttype and fieldname."""
if isinstance(field, dict): # for aggregates via qb
raise ValueError
key = field.split(" as ", 1)[0] key = field.split(" as ", 1)[0]
if key.startswith(("count(", "sum(", "avg(")): if key.startswith(("count(", "sum(", "avg(")):