From 83f88aa871e76a419b88b53eed07aef1cd4d860c Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Tue, 4 Oct 2016 22:30:16 +0200 Subject: [PATCH 1/2] Small usability improvements Replace README.md by README.rst (not finished) --- report_py3o/README.md | 18 ----- report_py3o/README.rst | 94 ++++++++++++++++++++++++ report_py3o/__openerp__.py | 14 ++-- report_py3o/models/ir_report.py | 4 +- report_py3o/models/py3o_server.py | 6 +- report_py3o/models/py3o_template.py | 2 +- report_py3o/security/ir.model.access.csv | 2 +- report_py3o/views/ir_report.xml | 3 +- report_py3o/views/py3o_server.xml | 18 ++--- report_py3o/views/py3o_template.xml | 26 +++---- 10 files changed, 130 insertions(+), 57 deletions(-) delete mode 100644 report_py3o/README.md create mode 100644 report_py3o/README.rst diff --git a/report_py3o/README.md b/report_py3o/README.md deleted file mode 100644 index 51709d3d11..0000000000 --- a/report_py3o/README.md +++ /dev/null @@ -1,18 +0,0 @@ -### README ### - - -### LibreOffice Report Engine for Odoo/OpenERP ### - - -This module allows you to convert any type of report into LibreOffice/OpenOffice. -The benefits is that you have control over your documents and you can -modify them as needed. - - -Requirements -============ - -The py3o.template package is required; install it with: - easy_install -UZ py3o.template - - diff --git a/report_py3o/README.rst b/report_py3o/README.rst new file mode 100644 index 0000000000..cf4d70620a --- /dev/null +++ b/report_py3o/README.rst @@ -0,0 +1,94 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +=========== +Report Py3o +=========== + +The py3o reporting engine is a reporting engine for Odoo based on `Libreoffice `_: + +* the report is created with Libreoffice (ODT or ODS), +* the report is stored on the server in OpenDocument format (.odt or .ods file) +* the report is sent to the user in OpenDocument format or in any output format supported by Libreoffice (PDF, HTML, DOC, DOCX, Docbook, XLS, etc.) + +The key advantages of a Libreoffice-based reporting engine are: + +* no need to be a developper to create or modify a report: the report is created and modified with Libreoffice. So this reporting engine has a fully WYSIWYG report developpment tool! + +* For a PDF report in A4/Letter format, it's easier to develop it with a tool such as Libreoffice that is designed to create A4/Letter documents than to develop it in HTML/CSS. + +* If you want your users to be able to modify the document after its generation by Odoo, just configure the document with ODT output (or DOC or DOCX) and the user will be able to modify the document with Libreoffice (or Word) after its generation by Odoo. + +* Easy development of spreadsheet reports in ODS format (XLS output possible). + +This reporting engine is an alternative to `Aeroo `_: these 2 reporting engines have similar features but their codes are completely different. + +Installation +============ + +You must install 2 additionnal python libs: + +.. code:: + + pip install py3o.template + pip install py3o.formats + +If you want to convert the ODT or ODS report in another format, you need several additionnal components and Python libs: + +* `Py3o Fusion server `_ +* `Py3o render server `_ +* Libreoffice started in the background in headless mode. + +TODO : continue + +Configuration +============= + +If you want to convert the report in another format, go to the menu *Configuration > Technical > Reports > Py3o > Py3o Servers* and create a new Py3o server with its URL (for example: http://localhost:8765/form). + +TODO: continue + +Usage +===== + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/143/9.0 + +Known issues / Roadmap +====================== + +* generate barcode ? + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues +`_. In case of trouble, please +check there if your issue has already been reported. If you spotted it first, +help us smashing it by providing a detailed and welcomed feedback. + +Credits +======= + +Contributors +------------ + +* Florent Aide (`XCG Consulting `_) +* Laurent Mignon (Acsone) + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +To contribute to this module, please visit https://odoo-community.org. diff --git a/report_py3o/__openerp__.py b/report_py3o/__openerp__.py index e86cc6fa82..e4f1cd437b 100644 --- a/report_py3o/__openerp__.py +++ b/report_py3o/__openerp__.py @@ -3,20 +3,16 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { 'name': 'LibreOffice Report Engine', - 'description': ''' -Generation of LibreOffice/OpenOffice reports using LibreOffice/OpenOffice -templates. - -The py3o.template package is required; install it with: - pip install py3o.template -''', + 'summary': 'Reporting engine based on Libreoffice (ODT -> ODT, ' + 'ODT -> PDF, ODT -> DOC, ODT -> DOCX, ODS -> ODS, etc.)', 'version': '9.0.1.0.0', 'category': 'Reporting', - 'author': 'XCG Consulting', + 'license': 'AGPL-3', + 'author': 'XCG Consulting,Odoo Community Association (OCA)', 'website': 'http://odoo.consulting/', 'depends': [ 'base', - 'report' + 'report', ], 'external_dependencies': { 'python': ['py3o.template', diff --git a/report_py3o/models/ir_report.py b/report_py3o/models/ir_report.py index 418b71058c..37d017ee12 100644 --- a/report_py3o/models/ir_report.py +++ b/report_py3o/models/ir_report.py @@ -55,14 +55,14 @@ def _get_py3o_filetypes(self): 'py3o.template', "Template") py3o_is_local_fusion = fields.Boolean( - "Local fusion", + "Local Fusion", help="Native formats will be processed without a server. " "You must use this mode if you call methods on your model into " "the template.", default=True) py3o_server_id = fields.Many2one( "py3o.server", - "Fusion server") + "Fusion Server") module = fields.Char( "Module", help="The implementer module that provides this report") diff --git a/report_py3o/models/py3o_server.py b/report_py3o/models/py3o_server.py index bf434a5941..1808c3f7d5 100644 --- a/report_py3o/models/py3o_server.py +++ b/report_py3o/models/py3o_server.py @@ -6,6 +6,10 @@ class Py3oServer(models.Model): _name = 'py3o.server' + _rec_name = 'url' - url = fields.Char("URL", required=True) + url = fields.Char( + "Py3o Fusion Server URL", required=True, + help="If your Py3o Fusion server is on the same machine and runs " + "on the default port, the URL is http://localhost:8765/form") is_active = fields.Boolean("Active", default=True) diff --git a/report_py3o/models/py3o_template.py b/report_py3o/models/py3o_template.py index 5f46179ded..f7873a5af5 100644 --- a/report_py3o/models/py3o_template.py +++ b/report_py3o/models/py3o_template.py @@ -8,7 +8,7 @@ class Py3oTemplate(models.Model): _name = 'py3o.template' name = fields.Char(required=True) - py3o_template_data = fields.Binary("LibreOffice template") + py3o_template_data = fields.Binary("LibreOffice Template") filetype = fields.Selection( selection=[ ('odt', "ODF Text Document"), diff --git a/report_py3o/security/ir.model.access.csv b/report_py3o/security/ir.model.access.csv index c6ba6f7688..f43cac061c 100644 --- a/report_py3o/security/ir.model.access.csv +++ b/report_py3o/security/ir.model.access.csv @@ -2,4 +2,4 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink access_py3o_template_admin,access_py3o_template_admin,model_py3o_template,base.group_no_one,1,1,1,1 access_py3o_template_user,access_py3o_template_user,model_py3o_template,base.group_user,1,0,0,0 access_py3o_server_admin,access_py3o_server_admin,model_py3o_server,base.group_no_one,1,1,1,1 -access_py3o_server_user,access_py3o_server_user,model_py3o_server,base.group_user,1,0,0,0 \ No newline at end of file +access_py3o_server_user,access_py3o_server_user,model_py3o_server,base.group_user,1,0,0,0 diff --git a/report_py3o/views/ir_report.xml b/report_py3o/views/ir_report.xml index 8e923ec2d9..1d01ca95ed 100644 --- a/report_py3o/views/ir_report.xml +++ b/report_py3o/views/ir_report.xml @@ -1,3 +1,4 @@ + @@ -10,7 +11,7 @@ - diff --git a/report_py3o/views/py3o_server.xml b/report_py3o/views/py3o_server.xml index 8a9682d4d3..dd936d8834 100644 --- a/report_py3o/views/py3o_server.xml +++ b/report_py3o/views/py3o_server.xml @@ -5,13 +5,11 @@ py3o.server.configuration.form.view py3o.server -
- - - - - - + + + + +
@@ -20,7 +18,7 @@ py3o.server.configuration.tree.view py3o.server - + @@ -28,14 +26,12 @@ - py3o.server.configuration.action + Py3o Servers py3o.server - form tree,form
diff --git a/report_py3o/views/py3o_template.xml b/report_py3o/views/py3o_template.xml index 0ee57f37d4..93f459aa07 100644 --- a/report_py3o/views/py3o_template.xml +++ b/report_py3o/views/py3o_template.xml @@ -5,9 +5,13 @@ py3o.template.configuration.search.view py3o.template - + + + + @@ -16,14 +20,12 @@ py3o.template.configuration.form.view py3o.template -
- - - - - - - + + + + + +
@@ -32,7 +34,7 @@ py3o.template.configuration.tree.view py3o.template - + @@ -40,14 +42,12 @@ - Py3o Templates Configuration + Py3o Templates py3o.template - form tree,form From 2fbbdc9846448b2a21a669fd34e4255db6dab02e Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Wed, 5 Oct 2016 09:50:57 +0200 Subject: [PATCH 2/2] Take into accounts most remarks of @lasley Remove in views Protect import of py3o libs Remove dep on base module Other small changes --- report_py3o/NEWS | 4 -- report_py3o/__openerp__.py | 7 +-- report_py3o/models/ir_report.py | 21 ++++--- report_py3o/py3o_parser.py | 17 ++++-- report_py3o/views/ir_report.xml | 45 +++++++-------- report_py3o/views/menu.xml | 10 ++-- report_py3o/views/py3o_server.xml | 62 ++++++++++---------- report_py3o/views/py3o_template.xml | 90 ++++++++++++++--------------- 8 files changed, 132 insertions(+), 124 deletions(-) delete mode 100644 report_py3o/NEWS diff --git a/report_py3o/NEWS b/report_py3o/NEWS deleted file mode 100644 index f993a6ca93..0000000000 --- a/report_py3o/NEWS +++ /dev/null @@ -1,4 +0,0 @@ -report_py3o 1.3 - -Production release - diff --git a/report_py3o/__openerp__.py b/report_py3o/__openerp__.py index e4f1cd437b..26378bb70f 100644 --- a/report_py3o/__openerp__.py +++ b/report_py3o/__openerp__.py @@ -2,7 +2,7 @@ # Copyright 2013 XCG Consulting (http://odoo.consulting) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { - 'name': 'LibreOffice Report Engine', + 'name': 'Py3o Report Engine', 'summary': 'Reporting engine based on Libreoffice (ODT -> ODT, ' 'ODT -> PDF, ODT -> DOC, ODT -> DOCX, ODS -> ODS, etc.)', 'version': '9.0.1.0.0', @@ -10,10 +10,7 @@ 'license': 'AGPL-3', 'author': 'XCG Consulting,Odoo Community Association (OCA)', 'website': 'http://odoo.consulting/', - 'depends': [ - 'base', - 'report', - ], + 'depends': ['report'], 'external_dependencies': { 'python': ['py3o.template', 'py3o.formats'] diff --git a/report_py3o/models/ir_report.py b/report_py3o/models/ir_report.py index 37d017ee12..0c77f0d4b0 100644 --- a/report_py3o/models/ir_report.py +++ b/report_py3o/models/ir_report.py @@ -2,15 +2,22 @@ # Copyright 2013 XCG Consulting (http://odoo.consulting) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). import os -from py3o.formats import Formats from openerp import api, fields, models, _ from openerp.report.interface import report_int from openerp.exceptions import ValidationError from openerp import addons from ..py3o_parser import Py3oParser +import logging +logger = logging.getLogger(__name__) -class ReportXml(models.Model): +try: + from py3o.formats import Formats +except ImportError: + logger.debug('Cannot import py3o.formats') + + +class IrActionsReportXml(models.Model): """ Inherit from ir.actions.report.xml to allow customizing the template file. The user cam chose a template from a list. The list is configurable in the configuration tab, see py3o_template.py @@ -22,8 +29,8 @@ class ReportXml(models.Model): @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") + raise ValidationError(_( + "Field 'Output Format' is required for Py3O report")) @api.one @api.constrains("py3o_is_local_fusion", "py3o_server_id", @@ -32,9 +39,9 @@ def _check_py3o_server_id(self): is_native = Formats().get_format(self.py3o_filetype) if ((not is_native or not self.py3o_is_local_fusion) and not self.py3o_server_id): - raise ValidationError( + raise ValidationError(_( "Can not use not native format in local fusion. " - "Please specify a Fusion Server") + "Please specify a Fusion Server")) @api.model def _get_py3o_filetypes(self): @@ -116,4 +123,4 @@ def _lookup_report(self, cr, name): if new_report: return new_report else: - return super(ReportXml, self)._lookup_report(cr, name) + return super(IrActionsReportXml, self)._lookup_report(cr, name) diff --git a/report_py3o/py3o_parser.py b/report_py3o/py3o_parser.py index e32e1af4ac..853035acbf 100644 --- a/report_py3o/py3o_parser.py +++ b/report_py3o/py3o_parser.py @@ -9,14 +9,23 @@ from base64 import b64decode import requests from tempfile import NamedTemporaryFile -from py3o.template.helpers import Py3oConvertor -from py3o.template import Template -from py3o.formats import Formats - from openerp import _ from openerp import exceptions from openerp.report.report_sxw import report_sxw from openerp import registry +import logging + +logger = logging.getLogger(__name__) + +try: + from py3o.template.helpers import Py3oConvertor + from py3o.template import Template +except ImportError: + logger.debug('Cannot import py3o.template') +try: + from py3o.formats import Formats +except ImportError: + logger.debug('Cannot import py3o.formats') _extender_functions = {} diff --git a/report_py3o/views/ir_report.xml b/report_py3o/views/ir_report.xml index 1d01ca95ed..bc77db6f7a 100644 --- a/report_py3o/views/ir_report.xml +++ b/report_py3o/views/ir_report.xml @@ -1,32 +1,31 @@ - - + - - py3o_report_view - ir.actions.report.xml - - + + py3o_report_view + ir.actions.report.xml + + - - + + - - - - - - - - + + + + + + + + - - + + + + + - - - diff --git a/report_py3o/views/menu.xml b/report_py3o/views/menu.xml index 38388f3034..8960a20d01 100644 --- a/report_py3o/views/menu.xml +++ b/report_py3o/views/menu.xml @@ -1,8 +1,8 @@ - - - + + + diff --git a/report_py3o/views/py3o_server.xml b/report_py3o/views/py3o_server.xml index dd936d8834..7712305df6 100644 --- a/report_py3o/views/py3o_server.xml +++ b/report_py3o/views/py3o_server.xml @@ -1,38 +1,38 @@ - - - py3o.server.configuration.form.view - py3o.server - -
- - - - -
-
-
- - py3o.server.configuration.tree.view - py3o.server - - - + + py3o.server.configuration.form.view + py3o.server + +
+ + - - - + +
+
+
- - Py3o Servers - py3o.server - tree,form - + + py3o.server.configuration.tree.view + py3o.server + + + + + + + + + + Py3o Servers + py3o.server + tree,form + + + - -
diff --git a/report_py3o/views/py3o_template.xml b/report_py3o/views/py3o_template.xml index 93f459aa07..320376f8b3 100644 --- a/report_py3o/views/py3o_template.xml +++ b/report_py3o/views/py3o_template.xml @@ -1,54 +1,54 @@ - - - py3o.template.configuration.search.view - py3o.template - - - - - - - - - - - - py3o.template.configuration.form.view - py3o.template - -
- - - - - -
-
-
+ + py3o.template.configuration.search.view + py3o.template + + + + + + + + + + - - py3o.template.configuration.tree.view - py3o.template - - + + py3o.template.configuration.form.view + py3o.template + +
+ - - - + + +
+
+
+ + + py3o.template.configuration.tree.view + py3o.template + + + + + + + + + + Py3o Templates + py3o.template + tree,form + - - Py3o Templates - py3o.template - tree,form - + - -