@@ -104,7 +104,7 @@ def run(report_name, filters=None, user=None):
if cint(report.add_total_row) and result:
result = add_total_row(result, columns)
return {
"result": result,
"columns": columns,
@@ -129,6 +129,8 @@ def export_query():
file_format_type = data["file_format_type"]
if isinstance(data.get("visible_idx"), basestring):
visible_idx = json.loads(data.get("visible_idx"))
else:
visible_idx = None
if file_format_type == "Excel":
@@ -154,7 +156,8 @@ def export_query():
result = result + data.result
# filter rows by slickgrid's inline filter
result = [x for idx, x in enumerate(result) if idx == 0 or idx in visible_idx]
if visible_idx:
result = [x for idx, x in enumerate(result) if idx == 0 or idx in visible_idx]
from frappe.utils.xlsxutils import make_xlsx
xlsx_file = make_xlsx(result, "Query Report")
@@ -182,9 +185,12 @@ def add_total_row(result, columns, meta = None):
else:
col = col.split(":")
if len(col) > 1:
fieldtype = col[1]
if "/" in fieldtype:
fieldtype, options = fieldtype.split("/")
if col[1]:
fieldtype = col[1]
if "/" in fieldtype:
fieldtype, options = fieldtype.split("/")
else:
fieldtype = "Data"
else:
fieldtype = col.get("fieldtype")
options = col.get("options")
@@ -210,7 +216,7 @@ def add_total_row(result, columns, meta = None):
else:
first_col_fieldtype = columns[0].get("fieldtype")
if first_col_fieldtype not in ["Currency", "Int", "Float", "Percent"]:
if first_col_fieldtype not in ["Currency", "Int", "Float", "Percent", "Date" ]:
if first_col_fieldtype == "Link":
total_row[0] = "'" + _("Total") + "'"
else: