From 6b810c7fb57ca1a2c3d397959e0fbf99b6489939 Mon Sep 17 00:00:00 2001 From: Yenthe Van Ginneken Date: Wed, 12 Apr 2023 21:47:55 +0200 Subject: [PATCH 1/6] [FIX] report_xlsx: make sure variable is known Before this commit if another app crashes the "report_xlsx" controller it would go into the exception. However in the exception the following is called: _logger.exception("Error while generating report %s", reportname) As the except clause does not have the "reportname" variable it fails: Traceback (most recent call last): File "/home/odoo/src/odoo/odoo/addons/base/models/ir_http.py", line 237, in _dispatch result = request.dispatch() File "/home/odoo/src/odoo/odoo/http.py", line 804, in dispatch r = self._call_function(**self.params) File "/home/odoo/src/odoo/odoo/http.py", line 359, in _call_function return checked_call(self.db, *args, **kwargs) File "/home/odoo/src/odoo/odoo/service/model.py", line 94, in wrapper return f(dbname, *args, **kwargs) File "/home/odoo/src/odoo/odoo/http.py", line 348, in checked_call result = self.endpoint(*a, **kw) File "/home/odoo/src/odoo/odoo/http.py", line 910, in __call__ return self.method(*args, **kw) File "/home/odoo/src/odoo/odoo/http.py", line 535, in response_wrap response = f(*args, **kw) File "/home/odoo/src/user/report_xlsx/controllers/main.py", line 100, in report_download _logger.exception("Error while generating report %s", reportname) Exception By putting the "reportname" before the try it will always be available --- report_xlsx/controllers/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/report_xlsx/controllers/main.py b/report_xlsx/controllers/main.py index 9bae600e34..1f026e28f2 100644 --- a/report_xlsx/controllers/main.py +++ b/report_xlsx/controllers/main.py @@ -52,9 +52,9 @@ def report_routes(self, reportname, docids=None, converter=None, **data): def report_download(self, data, context=None): requestcontent = json.loads(data) url, report_type = requestcontent[0], requestcontent[1] + reportname = url.split("/report/xlsx/")[1].split("?")[0] try: if report_type == "xlsx": - reportname = url.split("/report/xlsx/")[1].split("?")[0] docids = None if "/" in reportname: reportname, docids = reportname.split("/") From 2eb2b5d3ae890700f1b3207abd9217bca8ea13d8 Mon Sep 17 00:00:00 2001 From: OCA-git-bot Date: Thu, 13 Apr 2023 08:41:29 +0000 Subject: [PATCH 2/6] report_xlsx 15.0.1.1.2 --- report_xlsx/__manifest__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/report_xlsx/__manifest__.py b/report_xlsx/__manifest__.py index 48d18f4ed4..bb583d52e2 100644 --- a/report_xlsx/__manifest__.py +++ b/report_xlsx/__manifest__.py @@ -6,7 +6,7 @@ "author": "ACSONE SA/NV," "Creu Blanca," "Odoo Community Association (OCA)", "website": "https://github.com/OCA/reporting-engine", "category": "Reporting", - "version": "15.0.1.1.1", + "version": "15.0.1.1.2", "development_status": "Mature", "license": "AGPL-3", "external_dependencies": {"python": ["xlsxwriter", "xlrd"]}, From 38cee4f4e65d658ab36529176af6c51fa62133b0 Mon Sep 17 00:00:00 2001 From: OCA-git-bot Date: Thu, 13 Apr 2023 08:41:50 +0000 Subject: [PATCH 3/6] [UPD] addons table in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ec7a394e00..bcfbb4fc4a 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ addon | version | maintainers | summary [report_qweb_parameter](report_qweb_parameter/) | 15.0.1.0.0 | | Add new parameters for qweb templates in order to reduce field length and check minimal length [report_qweb_pdf_watermark](report_qweb_pdf_watermark/) | 15.0.1.0.0 | | Add watermarks to your QWEB PDF reports [report_wkhtmltopdf_param](report_wkhtmltopdf_param/) | 15.0.1.0.0 | | Add new parameters for a paper format to be used by wkhtmltopdf command as arguments. -[report_xlsx](report_xlsx/) | 15.0.1.1.1 | | Base module to create xlsx report +[report_xlsx](report_xlsx/) | 15.0.1.1.2 | | Base module to create xlsx report [report_xlsx_helper](report_xlsx_helper/) | 15.0.1.0.1 | | Report xlsx helpers [report_xml](report_xml/) | 15.0.1.0.1 | | Allow to generate XML reports [sql_export](sql_export/) | 15.0.1.0.0 | | Export data in csv file with SQL requests From de2ce1f400db562a3fdc4a2d0d547ac238870780 Mon Sep 17 00:00:00 2001 From: Karl Southern Date: Thu, 13 Apr 2023 12:11:08 +0100 Subject: [PATCH 4/6] [FIX] IndexError thrown when attempting to split url by /report/xlsx when not a xlsx report --- report_xlsx/controllers/main.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/report_xlsx/controllers/main.py b/report_xlsx/controllers/main.py index 1f026e28f2..ec19218711 100644 --- a/report_xlsx/controllers/main.py +++ b/report_xlsx/controllers/main.py @@ -52,9 +52,10 @@ def report_routes(self, reportname, docids=None, converter=None, **data): def report_download(self, data, context=None): requestcontent = json.loads(data) url, report_type = requestcontent[0], requestcontent[1] - reportname = url.split("/report/xlsx/")[1].split("?")[0] - try: - if report_type == "xlsx": + if report_type == "xlsx": + reportname = url + try: + reportname = url.split("/report/xlsx/")[1].split("?")[0] docids = None if "/" in reportname: reportname, docids = reportname.split("/") @@ -95,10 +96,9 @@ def report_download(self, data, context=None): "Content-Disposition", content_disposition(filename) ) return response - else: - return super(ReportController, self).report_download(data, context) - 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))) + return super(ReportController, self).report_download(data, context) From 2a4c2b9b8243d1af383e80d227a1a48d74352021 Mon Sep 17 00:00:00 2001 From: OCA-git-bot Date: Thu, 13 Apr 2023 13:46:02 +0000 Subject: [PATCH 5/6] report_xlsx 15.0.1.1.3 --- report_xlsx/__manifest__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/report_xlsx/__manifest__.py b/report_xlsx/__manifest__.py index bb583d52e2..e6d87db958 100644 --- a/report_xlsx/__manifest__.py +++ b/report_xlsx/__manifest__.py @@ -6,7 +6,7 @@ "author": "ACSONE SA/NV," "Creu Blanca," "Odoo Community Association (OCA)", "website": "https://github.com/OCA/reporting-engine", "category": "Reporting", - "version": "15.0.1.1.2", + "version": "15.0.1.1.3", "development_status": "Mature", "license": "AGPL-3", "external_dependencies": {"python": ["xlsxwriter", "xlrd"]}, From 070e758711bef7bb61fcf627a4fdb5be34341062 Mon Sep 17 00:00:00 2001 From: OCA-git-bot Date: Thu, 13 Apr 2023 13:46:08 +0000 Subject: [PATCH 6/6] [UPD] addons table in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bcfbb4fc4a..f4a5ba2f99 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ addon | version | maintainers | summary [report_qweb_parameter](report_qweb_parameter/) | 15.0.1.0.0 | | Add new parameters for qweb templates in order to reduce field length and check minimal length [report_qweb_pdf_watermark](report_qweb_pdf_watermark/) | 15.0.1.0.0 | | Add watermarks to your QWEB PDF reports [report_wkhtmltopdf_param](report_wkhtmltopdf_param/) | 15.0.1.0.0 | | Add new parameters for a paper format to be used by wkhtmltopdf command as arguments. -[report_xlsx](report_xlsx/) | 15.0.1.1.2 | | Base module to create xlsx report +[report_xlsx](report_xlsx/) | 15.0.1.1.3 | | Base module to create xlsx report [report_xlsx_helper](report_xlsx_helper/) | 15.0.1.0.1 | | Report xlsx helpers [report_xml](report_xml/) | 15.0.1.0.1 | | Allow to generate XML reports [sql_export](sql_export/) | 15.0.1.0.0 | | Export data in csv file with SQL requests