From 6b55c4ef0d67a6aa0ab57730325d09fc4a69c2c6 Mon Sep 17 00:00:00 2001 From: "Laurent Mignon (ACSONE)" Date: Mon, 26 Nov 2018 17:58:30 +0100 Subject: [PATCH] [MIG] report_py3o, report_py3o_fusion_server: Migration to 12.0 --- report_py3o_fusion_server/__init__.py | 1 - report_py3o_fusion_server/__manifest__.py | 5 ++--- .../demo/report_py3o.xml | 2 +- report_py3o_fusion_server/models/__init__.py | 3 +-- ...ons_report_xml.py => ir_actions_report.py} | 5 ++--- .../models/py3o_pdf_options.py | 1 - .../models/py3o_report.py | 19 +++++++++---------- .../models/py3o_server.py | 2 +- report_py3o_fusion_server/tests/__init__.py | 1 - .../tests/test_report_py3o_fusion_server.py | 1 - .../{ir_report.xml => ir_actions_report.xml} | 2 +- .../views/py3o_pdf_options.xml | 1 - 12 files changed, 17 insertions(+), 26 deletions(-) rename report_py3o_fusion_server/models/{ir_actions_report_xml.py => ir_actions_report.py} (93%) rename report_py3o_fusion_server/views/{ir_report.xml => ir_actions_report.xml} (90%) diff --git a/report_py3o_fusion_server/__init__.py b/report_py3o_fusion_server/__init__.py index a3e818a49..9c74cdad6 100644 --- a/report_py3o_fusion_server/__init__.py +++ b/report_py3o_fusion_server/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2017 Therp BV # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from . import models diff --git a/report_py3o_fusion_server/__manifest__.py b/report_py3o_fusion_server/__manifest__.py index 58d561c62..18b5126d2 100644 --- a/report_py3o_fusion_server/__manifest__.py +++ b/report_py3o_fusion_server/__manifest__.py @@ -1,10 +1,9 @@ -# -*- coding: utf-8 -*- # Copyright 2017 Therp BV # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { 'name': 'Py3o Report Engine - Fusion server support', 'summary': 'Let the fusion server handle format conversion.', - 'version': '10.0.1.0.0', + 'version': '12.0.1.0.0', 'category': 'Reporting', 'license': 'AGPL-3', 'author': 'XCG Consulting,' @@ -23,7 +22,7 @@ "demo/py3o_pdf_options.xml", ], 'data': [ - "views/ir_report.xml", + "views/ir_actions_report.xml", 'security/ir.model.access.csv', 'views/py3o_server.xml', 'views/py3o_pdf_options.xml', diff --git a/report_py3o_fusion_server/demo/report_py3o.xml b/report_py3o_fusion_server/demo/report_py3o.xml index ac4f194ce..ce9de5c4e 100644 --- a/report_py3o_fusion_server/demo/report_py3o.xml +++ b/report_py3o_fusion_server/demo/report_py3o.xml @@ -1,6 +1,6 @@ - + diff --git a/report_py3o_fusion_server/models/__init__.py b/report_py3o_fusion_server/models/__init__.py index 8ae69cab1..5eec9fc3d 100644 --- a/report_py3o_fusion_server/models/__init__.py +++ b/report_py3o_fusion_server/models/__init__.py @@ -1,7 +1,6 @@ -# -*- coding: utf-8 -*- # Copyright 2017 Therp BV # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from . import ir_actions_report_xml +from . import ir_actions_report from . import py3o_pdf_options from . import py3o_report from . import py3o_server diff --git a/report_py3o_fusion_server/models/ir_actions_report_xml.py b/report_py3o_fusion_server/models/ir_actions_report.py similarity index 93% rename from report_py3o_fusion_server/models/ir_actions_report_xml.py rename to report_py3o_fusion_server/models/ir_actions_report.py index 167b4e627..f95a1b098 100644 --- a/report_py3o_fusion_server/models/ir_actions_report_xml.py +++ b/report_py3o_fusion_server/models/ir_actions_report.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # © 2013 XCG Consulting # © 2017 Therp BV # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). @@ -14,8 +13,8 @@ except ImportError: logger.debug('Cannot import py3o.formats') -class IrActionsReportXml(models.Model): - _inherit = 'ir.actions.report.xml' +class IrActionsReport(models.Model): + _inherit = 'ir.actions.report' @api.multi @api.constrains("py3o_is_local_fusion", "py3o_server_id", "py3o_filetype") diff --git a/report_py3o_fusion_server/models/py3o_pdf_options.py b/report_py3o_fusion_server/models/py3o_pdf_options.py index 1211feb94..d292fa18e 100644 --- a/report_py3o_fusion_server/models/py3o_pdf_options.py +++ b/report_py3o_fusion_server/models/py3o_pdf_options.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2018 Akretion (http://www.akretion.com) # @author: Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). diff --git a/report_py3o_fusion_server/models/py3o_report.py b/report_py3o_fusion_server/models/py3o_report.py index a4c9a1250..6e6cf507d 100644 --- a/report_py3o_fusion_server/models/py3o_report.py +++ b/report_py3o_fusion_server/models/py3o_report.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # © 2013 XCG Consulting # © 2016 ACSONE SA/NV # © 2017 Therp BV @@ -12,7 +11,7 @@ from datetime import datetime from contextlib import closing from openerp import _, api, models from openerp.exceptions import UserError -from StringIO import StringIO +from io import BytesIO logger = logging.getLogger(__name__) @@ -27,15 +26,15 @@ class Py3oReport(models.TransientModel): _inherit = 'py3o.report' @api.multi - def _create_single_report(self, model_instance, data, save_in_attachment): + def _create_single_report(self, model_instance, data): """ This function to generate our py3o report """ self.ensure_one() - report_xml = self.ir_actions_report_xml_id + report_xml = self.ir_actions_report_id filetype = report_xml.py3o_filetype if not report_xml.py3o_server_id: return super(Py3oReport, self)._create_single_report( - model_instance, data, save_in_attachment, + model_instance, data, ) elif report_xml.py3o_is_local_fusion: result_path = super( @@ -43,9 +42,9 @@ class Py3oReport(models.TransientModel): report_py3o_skip_conversion=True, ) )._create_single_report( - model_instance, data, save_in_attachment, + model_instance, data ) - with closing(open(result_path, 'r')) as out_stream: + with closing(open(result_path, 'rb')) as out_stream: tmpl_data = out_stream.read() datadict = {} else: @@ -53,8 +52,8 @@ class Py3oReport(models.TransientModel): suffix='.' + filetype, prefix='p3o.report.tmp.') tmpl_data = self.get_template(model_instance) - in_stream = StringIO(tmpl_data) - with closing(os.fdopen(result_fd, 'w+')) as out_stream: + in_stream = BytesIO(tmpl_data) + with closing(os.fdopen(result_fd, 'wb+')) as out_stream: template = Template(in_stream, out_stream, escape_false=True) localcontext = self._get_parser_context(model_instance, data) expressions = template.get_all_user_python_expression() @@ -107,5 +106,5 @@ class Py3oReport(models.TransientModel): report_xml.report_name, filetype, convert_seconds) if len(model_instance) == 1: self._postprocess_report( - result_path, model_instance.id, save_in_attachment) + result_path, model_instance.id) return result_path diff --git a/report_py3o_fusion_server/models/py3o_server.py b/report_py3o_fusion_server/models/py3o_server.py index 30d7d81aa..cab1ee2f8 100644 --- a/report_py3o_fusion_server/models/py3o_server.py +++ b/report_py3o_fusion_server/models/py3o_server.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2013 XCG Consulting (http://odoo.consulting) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo import fields, models @@ -6,6 +5,7 @@ from odoo import fields, models class Py3oServer(models.Model): _name = 'py3o.server' + _description = 'Py3o server' _rec_name = 'url' url = fields.Char( diff --git a/report_py3o_fusion_server/tests/__init__.py b/report_py3o_fusion_server/tests/__init__.py index 06cc0deea..546c2c05b 100644 --- a/report_py3o_fusion_server/tests/__init__.py +++ b/report_py3o_fusion_server/tests/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2017 Therp BV # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from . import test_report_py3o_fusion_server diff --git a/report_py3o_fusion_server/tests/test_report_py3o_fusion_server.py b/report_py3o_fusion_server/tests/test_report_py3o_fusion_server.py index 127ed9673..6fb4d0e74 100644 --- a/report_py3o_fusion_server/tests/test_report_py3o_fusion_server.py +++ b/report_py3o_fusion_server/tests/test_report_py3o_fusion_server.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2017 Therp BV # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). import mock diff --git a/report_py3o_fusion_server/views/ir_report.xml b/report_py3o_fusion_server/views/ir_actions_report.xml similarity index 90% rename from report_py3o_fusion_server/views/ir_report.xml rename to report_py3o_fusion_server/views/ir_actions_report.xml index 173d6b3ef..a013fba3d 100644 --- a/report_py3o_fusion_server/views/ir_report.xml +++ b/report_py3o_fusion_server/views/ir_actions_report.xml @@ -1,7 +1,7 @@ - ir.actions.report.xml + ir.actions.report diff --git a/report_py3o_fusion_server/views/py3o_pdf_options.xml b/report_py3o_fusion_server/views/py3o_pdf_options.xml index 3109758a4..dfade7099 100644 --- a/report_py3o_fusion_server/views/py3o_pdf_options.xml +++ b/report_py3o_fusion_server/views/py3o_pdf_options.xml @@ -27,7 +27,6 @@