mirror of
https://github.com/OCA/reporting-engine.git
synced 2025-02-16 16:30:38 +02:00
[MIG] report_xlsx: Migration to 12.0
* refactor: On new ActionManager override _makeReportUrls and triggerDownload to support XLSX format * pass action to custom _downloadReportXLSX: Need action to get report data * dict constructor to remove context lang
This commit is contained in:
committed by
tien-ld
parent
17fa60eb46
commit
1589c25a34
@@ -6,28 +6,30 @@ from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class ReportAction(models.Model):
|
||||
_inherit = 'ir.actions.report'
|
||||
_inherit = "ir.actions.report"
|
||||
|
||||
report_type = fields.Selection(selection_add=[("xlsx", "xlsx")])
|
||||
report_type = fields.Selection(selection_add=[("xlsx", "XLSX")])
|
||||
|
||||
@api.model
|
||||
def render_xlsx(self, docids, data):
|
||||
report_model_name = 'report.%s' % self.report_name
|
||||
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_xlsx_report(docids, data)
|
||||
raise UserError(_("%s model was not found" % report_model_name))
|
||||
return report_model.with_context(active_model=self.model).create_xlsx_report( # noqa
|
||||
docids, data
|
||||
)
|
||||
|
||||
@api.model
|
||||
def _get_report_from_name(self, report_name):
|
||||
res = super(ReportAction, self)._get_report_from_name(report_name)
|
||||
if res:
|
||||
return res
|
||||
report_obj = self.env['ir.actions.report']
|
||||
qwebtypes = ['xlsx']
|
||||
conditions = [('report_type', 'in', qwebtypes),
|
||||
('report_name', '=', report_name)]
|
||||
context = self.env['res.users'].context_get()
|
||||
report_obj = self.env["ir.actions.report"]
|
||||
qwebtypes = ["xlsx"]
|
||||
conditions = [
|
||||
("report_type", "in", qwebtypes),
|
||||
("report_name", "=", report_name),
|
||||
]
|
||||
context = self.env["res.users"].context_get()
|
||||
return report_obj.with_context(context).search(conditions, limit=1)
|
||||
|
||||
Reference in New Issue
Block a user