diff --git a/report_generate_helper/models/__init__.py b/report_generate_helper/models/__init__.py index e3045815c5..cb428c1371 100644 --- a/report_generate_helper/models/__init__.py +++ b/report_generate_helper/models/__init__.py @@ -1 +1,2 @@ -from . import report_helper +from . import base +from . import ir_actions_report diff --git a/report_generate_helper/models/report_helper.py b/report_generate_helper/models/base.py similarity index 77% rename from report_generate_helper/models/report_helper.py rename to report_generate_helper/models/base.py index cd013eb470..fb213fdb76 100644 --- a/report_generate_helper/models/report_helper.py +++ b/report_generate_helper/models/base.py @@ -9,10 +9,13 @@ class Base(models.AbstractModel): _inherit = "base" - def _get_report_converter(self): - return f"_render_{self.report_type.replace('-', '_')}" + def _generate_report(self, report_name): + """ + Generate the report matching the report_name for the self object - def get_report(self, report_name): + The method will return a tuple with the name of the field and the content + return (filename, content) + """ report = self.env["ir.actions.report"]._get_report(report_name) method_name = report._get_report_converter() diff --git a/report_generate_helper/models/ir_actions_report.py b/report_generate_helper/models/ir_actions_report.py new file mode 100644 index 0000000000..7ae3c68c72 --- /dev/null +++ b/report_generate_helper/models/ir_actions_report.py @@ -0,0 +1,13 @@ +# Copyright 2024 Akretion (https://www.akretion.com). +# @author Sébastien BEAU +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + + +from odoo import models + + +class IrActionsActions(models.Model): + _inherit = "ir.actions.report" + + def _get_report_converter(self): + return f"_render_{self.report_type.replace('-', '_')}" diff --git a/report_generate_helper/tests/test_report_generate_helper.py b/report_generate_helper/tests/test_report_generate_helper.py index 7740bd7249..9df4f35e3a 100644 --- a/report_generate_helper/tests/test_report_generate_helper.py +++ b/report_generate_helper/tests/test_report_generate_helper.py @@ -4,4 +4,4 @@ class TestReportLabel(common.TransactionCase): def test_get_report(self): module = self.env["ir.module.module"].search([])[1] - self.assertTrue(module.get_report("base.report_irmodulereference")) + self.assertTrue(module._generate_report("base.report_irmodulereference"))