diff --git a/report_qweb_txt/models/ir_actions_report_xml.py b/report_qweb_txt/models/ir_actions_report_xml.py index 432ef956..084d83fd 100644 --- a/report_qweb_txt/models/ir_actions_report_xml.py +++ b/report_qweb_txt/models/ir_actions_report_xml.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- -# © 2016 Akretion (Alexis de Lattre ) +# © 2016-2018 Akretion (Alexis de Lattre ) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import models, fields, api +from odoo import api, fields, models class IrActionsReportXml(models.Model): diff --git a/report_qweb_txt/models/report.py b/report_qweb_txt/models/report.py index e945e0b2..dc12758d 100644 --- a/report_qweb_txt/models/report.py +++ b/report_qweb_txt/models/report.py @@ -1,9 +1,8 @@ # -*- coding: utf-8 -*- -# © 2016 Akretion (Alexis de Lattre ) +# © 2016-2018 Akretion (Alexis de Lattre ) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import models, api, _ -from odoo.exceptions import UserError +from odoo import api, models class Report(models.Model): @@ -11,10 +10,9 @@ class Report(models.Model): @api.model def _get_report_from_name(self, report_name): - reports = self.env['ir.actions.report.xml'].search([ - ('report_type', '!=', False), - ('report_name', '=', report_name)]) - if not reports: - raise UserError(_( - "No report named '%s' found.") % report_name) - return reports[0] + res = super(Report, self)._get_report_from_name(report_name) + if not res: + res = self.env['ir.actions.report.xml'].search([ + ('report_type', '!=', False), + ('report_name', '=', report_name)], limit=1) + return res