[MIG] report_csv: Migration to 16.0

This commit is contained in:
Zina Rasoamanana
2022-11-08 14:35:39 +01:00
parent 9686db699e
commit 355981cf4e
4 changed files with 16 additions and 16 deletions

View File

@@ -1,8 +1,7 @@
# Copyright 2019 Creu Blanca
# 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,14 +12,13 @@ class ReportAction(models.Model):
)
@api.model
def _render_csv(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)
return report_model.with_context(active_model=self.model).create_csv_report(
docids, data
)
def _render_csv(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=report_sudo.model
).create_csv_report(docids, data)
@api.model
def _get_report_from_name(self, report_name):