From e793d39969e0e1354aed5fe9dd262386b8eeb5ec Mon Sep 17 00:00:00 2001 From: Omar Date: Tue, 31 Oct 2017 11:17:17 +0100 Subject: [PATCH 1/5] [IMP] report_py3o: Allows to interpret \n and \t in texts, cleans html tags too --- report_py3o/models/py3o_report.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/report_py3o/models/py3o_report.py b/report_py3o/models/py3o_report.py index 24b1af45..a892dec1 100644 --- a/report_py3o/models/py3o_report.py +++ b/report_py3o/models/py3o_report.py @@ -9,6 +9,7 @@ import json import logging import os from contextlib import closing +from genshi.core import Markup import pkg_resources import requests @@ -64,12 +65,22 @@ def py3o_report_extender(report_xml_id=None): return fct1 +def format_multiline_value(value): + if value: + return Markup(unicode(value).replace('<', '<').replace('>', '>'). + replace('\n', ''). + replace('\t', '')) + return "" + + @py3o_report_extender() def defautl_extend(report_xml, localcontext): # add the base64decode function to be able do decode binary fields into # the template localcontext['b64decode'] = b64decode localcontext['report_xml'] = report_xml + localcontext['format_multiline_value'] = format_multiline_value + localcontext['html_sanitize'] = tools.html2plaintext class Py3oReport(models.TransientModel): From 318d8ff4aa979a2974bfa1b81bad1806f3252c30 Mon Sep 17 00:00:00 2001 From: omar7r Date: Tue, 7 Nov 2017 20:16:05 +0100 Subject: [PATCH 2/5] [FIX] Deletes an unnecessary function call --- report_py3o/models/py3o_report.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/report_py3o/models/py3o_report.py b/report_py3o/models/py3o_report.py index a892dec1..01decb42 100644 --- a/report_py3o/models/py3o_report.py +++ b/report_py3o/models/py3o_report.py @@ -67,7 +67,7 @@ def py3o_report_extender(report_xml_id=None): def format_multiline_value(value): if value: - return Markup(unicode(value).replace('<', '<').replace('>', '>'). + return Markup(value.replace('<', '<').replace('>', '>'). replace('\n', ''). replace('\t', '')) return "" From be3bd5bf6e2c532586e580f6b218bdeb08d46807 Mon Sep 17 00:00:00 2001 From: Omar Date: Thu, 9 Nov 2017 11:05:01 +0100 Subject: [PATCH 3/5] [FIX] report_py3o: Removes api.one --- report_py3o/models/ir_actions_report_xml.py | 27 +++++++++++---------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/report_py3o/models/ir_actions_report_xml.py b/report_py3o/models/ir_actions_report_xml.py index 66d9a5fc..7298486e 100644 --- a/report_py3o/models/ir_actions_report_xml.py +++ b/report_py3o/models/ir_actions_report_xml.py @@ -23,25 +23,26 @@ class IrActionsReportXml(models.Model): _inherit = 'ir.actions.report.xml' - @api.one + @api.multi @api.constrains("py3o_filetype", "report_type") def _check_py3o_filetype(self): - if self.report_type == "py3o" and not self.py3o_filetype: - raise ValidationError(_( - "Field 'Output Format' is required for Py3O report")) + for report in self: + if report.report_type == "py3o" and not report.py3o_filetype: + raise ValidationError(_( + "Field 'Output Format' is required for Py3O report")) - @api.one + @api.multi @api.constrains("py3o_is_local_fusion", "py3o_server_id", "py3o_filetype") def _check_py3o_server_id(self): - if self.report_type != "py3o": - return - is_native = Formats().get_format(self.py3o_filetype).native - if ((not is_native or not self.py3o_is_local_fusion) and - not self.py3o_server_id): - raise ValidationError(_( - "Can not use not native format in local fusion. " - "Please specify a Fusion Server")) + for report in self: + if report.report_type == "py3o": + is_native = Formats().get_format(report.py3o_filetype).native + if ((not is_native or not report.py3o_is_local_fusion) and + not report.py3o_server_id): + raise ValidationError(_( + "Can not use not native format in local fusion. " + "Please specify a Fusion Server")) @api.model def _get_py3o_filetypes(self): From ae71d876a3569a91c26f40bca927a2b3152a3d7c Mon Sep 17 00:00:00 2001 From: Omar Date: Thu, 9 Nov 2017 11:28:11 +0100 Subject: [PATCH 4/5] [FIX] report_py3o: Import new dependencies in try...except --- report_py3o/models/py3o_report.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/report_py3o/models/py3o_report.py b/report_py3o/models/py3o_report.py index 01decb42..13f95c3a 100644 --- a/report_py3o/models/py3o_report.py +++ b/report_py3o/models/py3o_report.py @@ -9,7 +9,6 @@ import json import logging import os from contextlib import closing -from genshi.core import Markup import pkg_resources import requests @@ -28,6 +27,7 @@ try: from py3o.template.helpers import Py3oConvertor from py3o.template import Template from py3o import formats + from genshi.core import Markup except ImportError: logger.debug('Cannot import py3o.template') try: From 36fb229ed5d88fa5030b8d8bc9ab485b3fb42dee Mon Sep 17 00:00:00 2001 From: Omar Date: Fri, 10 Nov 2017 11:45:01 +0100 Subject: [PATCH 5/5] [UPD] report_py3o: Bump version --- report_py3o/README.rst | 1 + report_py3o/__manifest__.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/report_py3o/README.rst b/report_py3o/README.rst index 192965f5..aeefa0aa 100644 --- a/report_py3o/README.rst +++ b/report_py3o/README.rst @@ -240,6 +240,7 @@ Contributors * Laurent Mignon , * Alexis de Lattre , * Guewen Baconnier +* Omar CastiƱeira Maintainer diff --git a/report_py3o/__manifest__.py b/report_py3o/__manifest__.py index b42c1287..81e7fcd5 100644 --- a/report_py3o/__manifest__.py +++ b/report_py3o/__manifest__.py @@ -5,7 +5,7 @@ 'name': 'Py3o Report Engine', 'summary': 'Reporting engine based on Libreoffice (ODT -> ODT, ' 'ODT -> PDF, ODT -> DOC, ODT -> DOCX, ODS -> ODS, etc.)', - 'version': '10.0.1.1.0', + 'version': '10.0.1.2.0', 'category': 'Reporting', 'license': 'AGPL-3', 'author': 'XCG Consulting,'