[MIG] Migrate report_xlsx to 16.0

This commit is contained in:
Rodrigo
2022-11-30 12:49:15 +01:00
committed by tien-ld
parent 689bb01e2a
commit bc43cc47be
4 changed files with 18 additions and 20 deletions

View File

@@ -1,8 +1,7 @@
# Copyright 2015 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import _, api, fields, models
from odoo.exceptions import UserError
from odoo import api, fields, models
class ReportAction(models.Model):
@@ -13,20 +12,19 @@ class ReportAction(models.Model):
)
@api.model
def _render_xlsx(self, docids, data):
report_model_name = "report.%s" % self.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)
def _render_xlsx(self, report_ref, docids, data):
report_sudo = self._get_report(report_ref)
report_model_name = "report.%s" % report_sudo.report_name
report_model = self.env[report_model_name]
return (
report_model.with_context(active_model=self.model)
report_model.with_context(active_model=report_sudo.model)
.sudo(False)
.create_xlsx_report(docids, data) # noqa
)
@api.model
def _get_report_from_name(self, report_name):
res = super(ReportAction, self)._get_report_from_name(report_name)
res = super()._get_report_from_name(report_name)
if res:
return res
report_obj = self.env["ir.actions.report"]