[16.0][IMP] report_xml: Added xml_extension

Adds a way to choose the file extension for your XML file, by adding the flexibility of appending more choices.
For example, instead of getting `.xml`, this allows to have the report download as `.svg` or even good old `.html` if needed.
This is also very useful for some localization purposes, where some scarce software uses uncommon file extensions for their XML files, like `.ffdata` for specific accounting reports here in Lithuania.

The change is not breaking, as we set the default to be `.xml` like it was by default anyway.
This commit is contained in:
Mantux11
2023-01-27 09:11:02 +00:00
committed by Atte Isopuro
parent 8a1fe580c9
commit 01a303c127
4 changed files with 36 additions and 3 deletions

View File

@@ -70,7 +70,7 @@ class ReportController(report.ReportController):
report_name = safe_eval(
report.print_report_name, {"object": obj, "time": time}
)
filename = f"{report_name}.xml"
filename = f"{report_name}.{report.xml_extension}"
else:
data = url_parse(url).decode_query(cls=dict)
if "context" in data:
@@ -80,7 +80,7 @@ class ReportController(report.ReportController):
response = self.report_routes(
reportname, converter="xml", context=context, **data
)
filename = filename or f"{report.name}.xml"
filename = filename or f"{report.name}.{report.xml_extension}"
response.headers.add("Content-Disposition", content_disposition(filename))
return response
except Exception as e: