[FIX] report_xlsx: initialize reportname

pull/736/head
Anna Janiszewska 2023-03-10 14:31:06 +01:00 committed by MmeQuignon
parent 7f5c7b9004
commit 04b88a38bf
1 changed files with 9 additions and 9 deletions

View File

@ -52,8 +52,8 @@ class ReportController(ReportController):
def report_download(self, data, context=None, token=None):
requestcontent = json.loads(data)
url, report_type = requestcontent[0], requestcontent[1]
try:
if report_type == "xlsx":
if report_type == "xlsx":
try:
reportname = url.split("/report/xlsx/")[1].split("?")[0]
docids = None
if "/" in reportname:
@ -95,10 +95,10 @@ class ReportController(ReportController):
"Content-Disposition", content_disposition(filename)
)
return response
else:
return super().report_download(data, context=context, token=token)
except Exception as e:
_logger.exception("Error while generating report %s", reportname)
se = _serialize_exception(e)
error = {"code": 200, "message": "Odoo Server Error", "data": se}
return request.make_response(html_escape(json.dumps(error)))
except Exception as e:
_logger.exception("Error while generating report %s", reportname)
se = _serialize_exception(e)
error = {"code": 200, "message": "Odoo Server Error", "data": se}
return request.make_response(html_escape(json.dumps(error)))
else:
return super().report_download(data, context=context, token=token)