Merge pull request #31920 from sokumon/filters-in-report-name
fix: hard checks on report name length
This commit is contained in:
commit
9a1509bcf0
1 changed files with 13 additions and 6 deletions
|
|
@ -360,17 +360,24 @@ def export_query():
|
|||
content = make_xlsx(xlsx_data, "Query Report", column_widths=column_widths).getvalue()
|
||||
|
||||
for value in (data.filters or {}).values():
|
||||
if len(report_name) > 200:
|
||||
break
|
||||
|
||||
if isinstance(value, list) and value:
|
||||
report_name += "_" + ",".join(value)
|
||||
suffix = ""
|
||||
if isinstance(value, list):
|
||||
suffix = "_" + ",".join(value)
|
||||
elif isinstance(value, str) and value not in {"Yes", "No"}:
|
||||
report_name += f"_{value}"
|
||||
suffix = f"_{value}"
|
||||
|
||||
if valid_report_name(report_name, suffix):
|
||||
report_name += suffix
|
||||
|
||||
provide_binary_file(report_name, file_extension, content)
|
||||
|
||||
|
||||
def valid_report_name(report_name, suffix):
|
||||
if len(report_name) + len(suffix) < 200:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def format_fields(data: frappe._dict) -> None:
|
||||
for i, col in enumerate(data.columns):
|
||||
if col.get("fieldtype") == "Duration":
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue