mirror of
https://github.com/OCA/reporting-engine.git
synced 2025-02-16 16:30:38 +02:00
[MIG] report_csv: Backport from 11.0
This commit is contained in:
@@ -1 +1,2 @@
|
||||
from . import ir_report
|
||||
from . import report
|
||||
from . import ir_actions_report_xml
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2019 Creu Blanca
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
@@ -5,8 +6,8 @@ from odoo import api, fields, models, _
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class ReportAction(models.Model):
|
||||
_inherit = 'ir.actions.report'
|
||||
class IrActionsReportXml(models.Model):
|
||||
_inherit = 'ir.actions.report.xml'
|
||||
|
||||
report_type = fields.Selection(selection_add=[("csv", "csv")])
|
||||
|
||||
@@ -19,15 +20,3 @@ class ReportAction(models.Model):
|
||||
return report_model.with_context({
|
||||
'active_model': self.model
|
||||
}).create_csv_report(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 = ['csv']
|
||||
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)
|
||||
25
report_csv/models/report.py
Normal file
25
report_csv/models/report.py
Normal file
@@ -0,0 +1,25 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2017 Akretion (http://www.akretion.com/)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import api, models
|
||||
|
||||
|
||||
class Report(models.Model):
|
||||
|
||||
_inherit = 'report'
|
||||
|
||||
@api.model
|
||||
def _get_report_from_name(self, report_name):
|
||||
"""Get the first record of ir.actions.report.xml having the
|
||||
``report_name`` as value for the field report_name.
|
||||
"""
|
||||
res = super(Report, self)._get_report_from_name(report_name)
|
||||
if res:
|
||||
return res
|
||||
report_obj = self.env['ir.actions.report.xml']
|
||||
qwebtypes = ['csv']
|
||||
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