From 54623e111ac9adb4c6f9067ab7f32167f5419a94 Mon Sep 17 00:00:00 2001 From: Rivo Lalaina Date: Wed, 6 Nov 2024 14:42:50 +0300 Subject: [PATCH] [16.0] [MIG] report aeroo : handle exception --- report_aeroo/controllers/main.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/report_aeroo/controllers/main.py b/report_aeroo/controllers/main.py index 6cf712c..c0dadc9 100644 --- a/report_aeroo/controllers/main.py +++ b/report_aeroo/controllers/main.py @@ -29,20 +29,21 @@ def generate_aeroo_report(self, report_id, record_ids, token, debug=False): If the aeroo report is generated for multiple records, the file name is simply {report.name}.pdf. """ - report_id = int(report_id) - record_ids = json.loads(record_ids) + try: + report_id = int(report_id) + record_ids = json.loads(record_ids) - report = request.env["ir.actions.report"].browse(report_id) - content, out_format = report._render_aeroo(record_ids, {}) + report = request.env["ir.actions.report"].browse(report_id) + content, out_format = report._render_aeroo(record_ids, {}) - if len(record_ids) == 1: - record = request.env[report.model].browse(record_ids[0]) - file_name = report.get_aeroo_filename(record, out_format) - else: - file_name = "%s.%s" % (report.name, out_format) + if len(record_ids) == 1: + record = request.env[report.model].browse(record_ids[0]) + file_name = report.get_aeroo_filename(record, out_format) + else: + file_name = "%s.%s" % (report.name, out_format) + + report_mimetype = MIMETYPES_MAPPING.get(out_format, DEFAULT_MIMETYPE) - report_mimetype = MIMETYPES_MAPPING.get(out_format, DEFAULT_MIMETYPE) - try: response = request.make_response( content, headers=[