From af4dafac258dd5e46eee0aa4dda4be1a86dfd004 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Thu, 2 Mar 2017 09:09:03 +0100 Subject: [PATCH] [FIX] delete PDF invoice attachment on invoice back to draft (native feature now working with py3o) --- report_py3o/models/__init__.py | 1 + report_py3o/models/py3o_report.py | 14 -------------- report_py3o/models/report.py | 25 +++++++++++++++++++++++++ 3 files changed, 26 insertions(+), 14 deletions(-) create mode 100644 report_py3o/models/report.py diff --git a/report_py3o/models/__init__.py b/report_py3o/models/__init__.py index 425cb3d9..863d037d 100644 --- a/report_py3o/models/__init__.py +++ b/report_py3o/models/__init__.py @@ -1,4 +1,5 @@ from . import ir_actions_report_xml from . import py3o_template from . import py3o_server +from . import report from . import py3o_report diff --git a/report_py3o/models/py3o_report.py b/report_py3o/models/py3o_report.py index c0734ecd..5aa5d574 100644 --- a/report_py3o/models/py3o_report.py +++ b/report_py3o/models/py3o_report.py @@ -172,20 +172,6 @@ class Py3oReport(models.TransientModel): self._extend_parser_context(context_instance, report_xml) return context_instance.localcontext - @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(Py3oReport, self)._get_report_from_name(report_name) - if res: - return res - # maybe a py3o reprot - report_obj = self.env['ir.actions.report.xml'] - return report_obj.search( - [('report_type', '=', 'py3o'), - ('report_name', '=', report_name)]) - @api.model def _postprocess_report(self, report_path, res_id, save_in_attachment): if save_in_attachment.get(res_id): diff --git a/report_py3o/models/report.py b/report_py3o/models/report.py new file mode 100644 index 00000000..0666861c --- /dev/null +++ b/report_py3o/models/report.py @@ -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 + # maybe a py3o report + report_obj = self.env['ir.actions.report.xml'] + context = self.env['res.users'].context_get() + return report_obj.with_context(context).search( + [('report_type', '=', 'py3o'), + ('report_name', '=', report_name)], limit=1)