From 96f5c1704fb474f77bab63ef84711c485d1cfddb Mon Sep 17 00:00:00 2001 From: Luis Date: Wed, 19 Jan 2022 16:44:14 +0100 Subject: [PATCH] [MIG] report_xlsx_helper: Migration to 15.0 --- report_xlsx_helper/__manifest__.py | 2 +- report_xlsx_helper/controllers/main.py | 2 +- .../models/ir_actions_report.py | 2 +- report_xlsx_helper/readme/CONTRIBUTORS.rst | 2 ++ .../report/report_xlsx_abstract.py | 21 ++++++++++++------- .../tests/test_report_xlsx_helper.py | 2 +- 6 files changed, 19 insertions(+), 12 deletions(-) diff --git a/report_xlsx_helper/__manifest__.py b/report_xlsx_helper/__manifest__.py index 926969373..0c7e647b6 100644 --- a/report_xlsx_helper/__manifest__.py +++ b/report_xlsx_helper/__manifest__.py @@ -6,7 +6,7 @@ "author": "Noviat, Odoo Community Association (OCA)", "website": "https://github.com/OCA/reporting-engine", "category": "Reporting", - "version": "14.0.1.0.1", + "version": "15.0.1.0.0", "license": "AGPL-3", "depends": ["report_xlsx"], "installable": True, diff --git a/report_xlsx_helper/controllers/main.py b/report_xlsx_helper/controllers/main.py index e8542d5d8..0658e858e 100644 --- a/report_xlsx_helper/controllers/main.py +++ b/report_xlsx_helper/controllers/main.py @@ -32,7 +32,7 @@ class ReportController(ReportController): context.update(data["context"]) context["report_name"] = reportname - xlsx = report.with_context(context)._render_xlsx(docids, data=data)[0] + xlsx = report.with_context(**context)._render_xlsx(docids, data=data)[0] report_file = context.get("report_file") if not report_file: active_model = context.get("active_model", "export") diff --git a/report_xlsx_helper/models/ir_actions_report.py b/report_xlsx_helper/models/ir_actions_report.py index c64657298..7f6cf8d8d 100644 --- a/report_xlsx_helper/models/ir_actions_report.py +++ b/report_xlsx_helper/models/ir_actions_report.py @@ -14,6 +14,6 @@ class IrActionsReport(models.Model): report_model_name = "report.{}".format(self.env.context["report_name"]) report_model = self.env.get(report_model_name) if report_model is None: - raise UserError(_("%s model was not found" % report_model_name)) + raise UserError(_("%s model was not found") % report_model_name) return report_model.create_xlsx_report(docids, data) return super()._render_xlsx(docids, data) diff --git a/report_xlsx_helper/readme/CONTRIBUTORS.rst b/report_xlsx_helper/readme/CONTRIBUTORS.rst index 9df1ce27b..ee05b97de 100644 --- a/report_xlsx_helper/readme/CONTRIBUTORS.rst +++ b/report_xlsx_helper/readme/CONTRIBUTORS.rst @@ -1,3 +1,5 @@ * Luc De Meyer * Rattapong Chokmasermkul * Saran Lim. +* `Sinerkia Innovación y Desarrollo S.L. `_: + * Luis Pomar diff --git a/report_xlsx_helper/report/report_xlsx_abstract.py b/report_xlsx_helper/report/report_xlsx_abstract.py index 06a21a432..ed8d7a332 100644 --- a/report_xlsx_helper/report/report_xlsx_abstract.py +++ b/report_xlsx_helper/report/report_xlsx_abstract.py @@ -38,19 +38,20 @@ class ReportXlsxAbstract(models.AbstractModel): raise UserError( _( "Programming Error:\n\n" - "Excel Sheet name '%s' should not exceed %s characters." + "Excel Sheet name '%(name)s' should not exceed %(max_chars)s " + "characters." ) - % (name, max_chars) + % {"name": name, "max_chars": max_chars} ) special_chars = pattern.findall(name) if special_chars: raise UserError( _( "Programming Error:\n\n" - "Excel Sheet name '%s' contains unsupported special " - "characters: '%s'." + "Excel Sheet name '%(name)s' contains unsupported special " + "characters: '%(special_chars)s'." ) - % (name, special_chars) + % {"name": name, "special_chars": special_chars} ) return name @@ -709,10 +710,14 @@ class ReportXlsxAbstract(models.AbstractModel): cell_type = "blank" else: msg = _( - "%s, _write_line : programming error " + "%(__name__)s, _write_line : programming error " "detected while processing " - "col_specs_section %s, column %s" - ) % (__name__, col_specs_section, col) + "col_specs_section %(col_specs_section)s, column %(col)s" + ) % { + "__name__": __name__, + "col_specs_section": col_specs_section, + "col": col, + } if cell_value: msg += _(", cellvalue %s") % cell_value raise UserError(msg) diff --git a/report_xlsx_helper/tests/test_report_xlsx_helper.py b/report_xlsx_helper/tests/test_report_xlsx_helper.py index 461484d36..25c384edb 100644 --- a/report_xlsx_helper/tests/test_report_xlsx_helper.py +++ b/report_xlsx_helper/tests/test_report_xlsx_helper.py @@ -20,7 +20,7 @@ class TestReportXlsxHelper(TransactionCase): "active_model": "res.partner", "active_ids": self.partners.ids, } - self.report = self.env["ir.actions.report"].with_context(ctx) + self.report = self.env["ir.actions.report"].with_context(**ctx) def test_report_xlsx_helper(self): report_xls = self.report._render_xlsx(None, None)