mirror of
https://github.com/OCA/reporting-engine.git
synced 2025-02-16 16:30:38 +02:00
Merge pull request #172 from Comunitea/10.0_py3o_improvements
10.0 py3o improvements
This commit is contained in:
@@ -240,6 +240,7 @@ Contributors
|
||||
* Laurent Mignon <laurent.mignon@acsone.eu>,
|
||||
* Alexis de Lattre <alexis.delattre@akretion.com>,
|
||||
* Guewen Baconnier <guewen.baconnier@camptocamp.com>
|
||||
* Omar Castiñeira <omar@comunitea.com>
|
||||
|
||||
|
||||
Maintainer
|
||||
|
||||
@@ -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,'
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -27,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:
|
||||
@@ -64,12 +65,22 @@ def py3o_report_extender(report_xml_id=None):
|
||||
return fct1
|
||||
|
||||
|
||||
def format_multiline_value(value):
|
||||
if value:
|
||||
return Markup(value.replace('<', '<').replace('>', '>').
|
||||
replace('\n', '<text:line-break/>').
|
||||
replace('\t', '<text:s/><text:s/><text:s/><text:s/>'))
|
||||
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):
|
||||
|
||||
Reference in New Issue
Block a user