Browse Source

[14.0][MIG] report_xlsx_helper

14.0
Saran440 4 years ago
parent
commit
e928294e78
  1. 2
      report_xlsx_helper/__manifest__.py
  2. 6
      report_xlsx_helper/controllers/main.py
  3. 4
      report_xlsx_helper/models/ir_actions_report.py
  4. 2
      report_xlsx_helper/report/report_xlsx_abstract.py
  5. 2
      report_xlsx_helper/tests/test_report_xlsx_helper.py
  6. 1
      setup/report_xlsx_helper/odoo/addons/report_xlsx_helper
  7. 6
      setup/report_xlsx_helper/setup.py

2
report_xlsx_helper/__manifest__.py

@ -6,7 +6,7 @@
"author": "Noviat, Odoo Community Association (OCA)", "author": "Noviat, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/reporting-engine", "website": "https://github.com/OCA/reporting-engine",
"category": "Reporting", "category": "Reporting",
"version": "13.0.1.1.0",
"version": "14.0.1.0.0",
"license": "AGPL-3", "license": "AGPL-3",
"depends": ["report_xlsx"], "depends": ["report_xlsx"],
"installable": True, "installable": True,

6
report_xlsx_helper/controllers/main.py

@ -37,7 +37,7 @@ class ReportController(ReportController):
context.update(data["context"]) context.update(data["context"])
context["report_name"] = reportname 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") report_file = context.get("report_file")
if not report_file: if not report_file:
active_model = context.get("active_model", "export") active_model = context.get("active_model", "export")
@ -52,6 +52,4 @@ class ReportController(ReportController):
("Content-Disposition", content_disposition(report_file + ".xlsx")), ("Content-Disposition", content_disposition(report_file + ".xlsx")),
] ]
return request.make_response(xlsx, headers=xlsxhttpheaders) return request.make_response(xlsx, headers=xlsxhttpheaders)
return super(ReportController, self).report_routes(
reportname, docids, converter, **data
)
return super().report_routes(reportname, docids, converter, **data)

4
report_xlsx_helper/models/ir_actions_report.py

@ -9,11 +9,11 @@ class IrActionsReport(models.Model):
_inherit = "ir.actions.report" _inherit = "ir.actions.report"
@api.model @api.model
def render_xlsx(self, docids, data):
def _render_xlsx(self, docids, data):
if not self and self.env.context.get("report_name"): if not self and self.env.context.get("report_name"):
report_model_name = "report.{}".format(self.env.context["report_name"]) report_model_name = "report.{}".format(self.env.context["report_name"])
report_model = self.env.get(report_model_name) report_model = self.env.get(report_model_name)
if report_model is None: 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 report_model.create_xlsx_report(docids, data)
return super(IrActionsReport, self).render_xlsx(docids, data)
return super()._render_xlsx(docids, data)

2
report_xlsx_helper/report/report_xlsx_abstract.py

@ -10,6 +10,8 @@ from xlsxwriter.utility import xl_rowcol_to_cell
from odoo import _, fields, models from odoo import _, fields, models
from odoo.exceptions import UserError from odoo.exceptions import UserError
_xxx = {}
class ReportXlsxAbstract(models.AbstractModel): class ReportXlsxAbstract(models.AbstractModel):
_inherit = "report.report_xlsx.abstract" _inherit = "report.report_xlsx.abstract"

2
report_xlsx_helper/tests/test_report_xlsx_helper.py

@ -23,5 +23,5 @@ class TestReportXlsxHelper(TransactionCase):
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): def test_report_xlsx_helper(self):
report_xls = self.report.render_xlsx(None, None)
report_xls = self.report._render_xlsx(None, None)
self.assertEqual(report_xls[1], "xlsx") self.assertEqual(report_xls[1], "xlsx")

1
setup/report_xlsx_helper/odoo/addons/report_xlsx_helper

@ -0,0 +1 @@
../../../../report_xlsx_helper

6
setup/report_xlsx_helper/setup.py

@ -0,0 +1,6 @@
import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
Loading…
Cancel
Save