Skip to content

Commit

Permalink
report_generate_helper: change method name, clean code, update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastienbeau committed Jun 3, 2024
1 parent d309e48 commit 692649a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
3 changes: 2 additions & 1 deletion report_generate_helper/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from . import report_helper
from . import base
from . import ir_actions_report
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
13 changes: 13 additions & 0 deletions report_generate_helper/models/ir_actions_report.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2024 Akretion (https://www.akretion.com).
# @author Sébastien BEAU <sebastien.beau@akretion.com>
# 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('-', '_')}"

0 comments on commit 692649a

Please sign in to comment.