From 1826aa2c4581123a6bee79bdd443a74f1f2c17e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Gavrel?= Date: Wed, 9 Mar 2016 17:50:37 +0100 Subject: [PATCH] Only use direct rendering as a fallback if no py3o server is defined --HG-- branch : odoo8 --- models/py3o_template.py | 1 + py3o_parser.py | 23 ++++++++++++----------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/models/py3o_template.py b/models/py3o_template.py index 44f6ddcf..29b49dfd 100644 --- a/models/py3o_template.py +++ b/models/py3o_template.py @@ -19,6 +19,7 @@ class py3o_template(osv.Model): ('ods', u"ODF Spreadsheet"), ], u"LibreOffice Template File Type", + required=True, ), } diff --git a/py3o_parser.py b/py3o_parser.py index 67f5b17b..3c21cc2f 100644 --- a/py3o_parser.py +++ b/py3o_parser.py @@ -156,20 +156,21 @@ class Py3oParser(report_sxw): parsed_datadict = data_struct.render(datadict) - if filetype.fusion_ext == report_xml.py3o_template_id.filetype: - # No format conversion is needed, render the template directly - template.render(parsed_datadict) - res = out_stream.getvalue() - - else: # Call py3o.server to render the template in the desired format - fusion_server_obj = pool.get('py3o.server') - fusion_server_ids = fusion_server_obj.search( - cr, uid, [], context=context - ) - if not fusion_server_ids: + fusion_server_obj = pool.get('py3o.server') + fusion_server_ids = fusion_server_obj.search( + cr, uid, [], context=context, limit=1 + ) + if not fusion_server_ids: + if filetype.fusion_ext == report_xml.py3o_template_id.filetype: + # No format conversion is needed, render the template directly + template.render(parsed_datadict) + res = out_stream.getvalue() + else: raise exceptions.MissingError( _(u"No Py3o server configuration found") ) + + else: # Call py3o.server to render the template in the desired format fusion_server_id = fusion_server_ids[0] fusion_server = fusion_server_obj.browse(