Skip to content

Commit dd6d142

Browse files
authored
Merge pull request #78 from akretion/10-port-py3o
[10.0] Port report_py3o
2 parents 6930d10 + 4aab7f9 commit dd6d142

24 files changed

Lines changed: 1867 additions & 0 deletions

report_py3o/LICENSE

Lines changed: 661 additions & 0 deletions
Large diffs are not rendered by default.

report_py3o/README.rst

Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
2+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
3+
:alt: License: AGPL-3
4+
5+
===========
6+
Report Py3o
7+
===========
8+
9+
The py3o reporting engine is a reporting engine for Odoo based on `Libreoffice <http://www.libreoffice.org/>`_:
10+
11+
* the report is created with Libreoffice (ODT or ODS),
12+
* the report is stored on the server in OpenDocument format (.odt or .ods file)
13+
* 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.)
14+
15+
The key advantages of a Libreoffice-based reporting engine are:
16+
17+
* 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!
18+
19+
* 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.
20+
21+
* 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.
22+
23+
* Easy development of spreadsheet reports in ODS format (XLS output possible).
24+
25+
This reporting engine is an alternative to `Aeroo <https://github.com/aeroo/aeroo_reports>`_: these 2 reporting engines have similar features but their codes are completely different.
26+
27+
Installation
28+
============
29+
30+
You must install 2 additionnal python libs:
31+
32+
.. code::
33+
34+
pip install py3o.template
35+
pip install py3o.formats
36+
37+
To allow the conversion of ODT or ODS reports to other formats (PDF, DOC, DOCX, etc.), you must install several additionnal components and Python libs:
38+
39+
* `Py3o Fusion server <https://bitbucket.org/faide/py3o.fusion>`_,
40+
* `Py3o render server <https://bitbucket.org/faide/py3o.renderserver>`_,
41+
* a Java Runtime Environment (JRE), which can be OpenJDK,
42+
* Libreoffice started in the background in headless mode,
43+
* the Java driver for Libreoffice (Juno).
44+
45+
It is also possible to use the Python driver for Libreoffice (PyUNO), but it is recommended to use the Java driver because it is more stable.
46+
47+
The installation procedure below uses the Java driver. It has been successfully tested on Ubuntu 16.04 LTS ; if you use another OS, you may have to change a few details.
48+
49+
Installation of py3o.fusion:
50+
51+
.. code::
52+
53+
pip install py3o.fusion
54+
pip install service-identity
55+
56+
Installation of py3o.renderserver:
57+
58+
.. code::
59+
60+
pip install py3o.renderserver
61+
62+
Installation of Libreoffice and JRE on Debian/Ubuntu:
63+
64+
.. code::
65+
66+
sudo apt-get install default-jre ure libreoffice-java-common libreoffice-writer
67+
68+
You may have to install additionnal fonts. For example, to have the special unicode symbols for phone/fax/email in the PDF reports generated by Py3o, you should install the following package:
69+
70+
.. code::
71+
72+
sudo apt-get install fonts-symbola
73+
74+
At the end, with the dependencies, you should have the following py3o python libs:
75+
76+
.. code::
77+
78+
% pip freeze | grep py3o
79+
py3o.formats==0.3
80+
py3o.fusion==0.8.6
81+
py3o.renderclient==0.2
82+
py3o.renderers.juno==0.8
83+
py3o.renderserver==0.5.1
84+
py3o.template==0.9.11
85+
py3o.types==0.1.1
86+
87+
Start the Py3o Fusion server:
88+
89+
.. code::
90+
91+
start-py3o-fusion --debug -s localhost
92+
93+
Start the Py3o render server:
94+
95+
.. code::
96+
97+
start-py3o-renderserver --java=/usr/lib/jvm/default-java/jre/lib/amd64/server/libjvm.so --ure=/usr/share --office=/usr/lib/libreoffice --driver=juno --sofficeport=8997
98+
99+
On the output of the Py3o render server, the first line looks like:
100+
101+
.. code::
102+
103+
DEBUG:root:Starting JVM: /usr/lib/jvm/default-java/jre/lib/amd64/server/libjvm.so with options: -Djava.class.path=/usr/local/lib/python2.7/dist-packages/py3o/renderers/juno/py3oconverter.jar:/usr/share/java/juh.jar:/usr/share/java/jurt.jar:/usr/share/java/ridl.jar:/usr/share/java/unoloader.jar:/usr/share/java/java_uno.jar:/usr/lib/libreoffice/program/classes/unoil.jar -Xmx150M
104+
105+
After **-Djava.class.path**, there is a list of Java libs with *.jar* extension ; check that each JAR file is really present on your filesystem. If one of the jar files is present in another directory, create a symlink that points to the real location of the file. If all the jar files are present on another directory, adapt the *--ure=* argument on the command line of Py3o render server.
106+
107+
To check that the Py3o Fusion server is running fine, visit the URL http://<IP_address>:8765/form. On this web page, under the section *Target format*, make sure that you have a line *This server currently supports these formats: ods, odt, docx, doc, html, docbook, pdf, xls.*.
108+
109+
Configuration
110+
=============
111+
112+
For example, to replace the native invoice report by a custom py3o report, add the following XML file in your custom module:
113+
114+
.. code::
115+
116+
<?xml version="1.0" encoding="utf-8"?>
117+
<odoo>
118+
119+
<record id="account.account_invoices" model="ir.actions.report.xml">
120+
<field name="report_type">py3o</field>
121+
<field name="py3o_filetype">odt</field>
122+
<field name="module">my_custom_module_base</field>
123+
<field name="py3o_template_fallback">report/account_invoice.odt</field>
124+
</record>
125+
126+
</odoo>
127+
128+
where *my_custom_module_base* is the name of the custom Odoo module. In this example, the invoice ODT file is located in *my_custom_module_base/report/account_invoice.odt*.
129+
130+
If you want an invoice in PDF format instead of ODT format, the XML file should look like:
131+
132+
.. code::
133+
134+
<?xml version="1.0" encoding="utf-8"?>
135+
<odoo>
136+
137+
<record id="local_py3o_server" model="py3o.server">
138+
<field name="url">http://localhost:8765/form</field>
139+
</record>
140+
141+
<record id="account.account_invoices" model="ir.actions.report.xml">
142+
<field name="report_type">py3o</field>
143+
<field name="py3o_filetype">pdf</field>
144+
<field name="py3o_server_id" ref="local_py3o_server"/>
145+
<field name="module">my_custom_module_base</field>
146+
<field name="py3o_template_fallback">report/account_invoice.odt</field>
147+
</record>
148+
149+
</odoo>
150+
151+
If you want to add a new py3o PDF report (and not replace a native report), the XML file should look like this:
152+
153+
.. code::
154+
155+
<?xml version="1.0" encoding="utf-8"?>
156+
<odoo>
157+
158+
<record id="local_py3o_server" model="py3o.server">
159+
<field name="url">http://localhost:8765/form</field>
160+
</record>
161+
162+
<record id="partner_summary_report" model="ir.actions.report.xml">
163+
<field name="name">Partner Summary</field>
164+
<field name="model">res.partner</field>
165+
<field name="report_name">res.partner.summary</field>
166+
<field name="report_type">py3o</field>
167+
<field name="py3o_filetype">pdf</field>
168+
<field name="py3o_server_id" ref="local_py3o_server"/>
169+
<field name="module">my_custom_module_base</field>
170+
<field name="py3o_template_fallback">report/partner_summary.odt</field>
171+
</record>
172+
173+
<!-- Add entry in "Print" drop-down list -->
174+
<record id="button_partner_summary_report" model="ir.values">
175+
<field name="key2">client_print_multi</field>
176+
<field name="model">res.partner</field>
177+
<field name="name">Partner Summary</field>
178+
<field name="value" eval="'ir.actions.report.xml,%d'%partner_summary_report" />
179+
</record>
180+
181+
</odoo>
182+
183+
Usage
184+
=====
185+
186+
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
187+
:alt: Try me on Runbot
188+
:target: https://runbot.odoo-community.org/runbot/143/10.0
189+
190+
Known issues / Roadmap
191+
======================
192+
193+
* generate barcode ?
194+
195+
Bug Tracker
196+
===========
197+
198+
Bugs are tracked on `GitHub Issues
199+
<https://github.com/OCA/reporting-engine/issues>`_. In case of trouble, please
200+
check there if your issue has already been reported. If you spotted it first,
201+
help us smashing it by providing a detailed and welcomed feedback.
202+
203+
Credits
204+
=======
205+
206+
Contributors
207+
------------
208+
209+
* Florent Aide (`XCG Consulting <http://odoo.consulting/>`_)
210+
* Laurent Mignon (Acsone)
211+
212+
Maintainer
213+
----------
214+
215+
.. image:: https://odoo-community.org/logo.png
216+
:alt: Odoo Community Association
217+
:target: https://odoo-community.org
218+
219+
This module is maintained by the OCA.
220+
221+
OCA, or the Odoo Community Association, is a nonprofit organization whose
222+
mission is to support the collaborative development of Odoo features and
223+
promote its widespread use.
224+
225+
To contribute to this module, please visit https://odoo-community.org.

report_py3o/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models

report_py3o/__manifest__.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright 2013 XCG Consulting (http://odoo.consulting)
3+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
4+
{
5+
'name': 'Py3o Report Engine',
6+
'summary': 'Reporting engine based on Libreoffice (ODT -> ODT, '
7+
'ODT -> PDF, ODT -> DOC, ODT -> DOCX, ODS -> ODS, etc.)',
8+
'version': '10.0.1.0.0',
9+
'category': 'Reporting',
10+
'license': 'AGPL-3',
11+
'author': 'XCG Consulting,Odoo Community Association (OCA)',
12+
'website': 'http://odoo.consulting/',
13+
'depends': ['report'],
14+
'external_dependencies': {
15+
'python': ['py3o.template',
16+
'py3o.formats']
17+
},
18+
'data': [
19+
'security/ir.model.access.csv',
20+
'views/menu.xml',
21+
'views/py3o_template.xml',
22+
'views/py3o_server.xml',
23+
'views/ir_report.xml',
24+
'demo/report_py3o.xml',
25+
],
26+
'installable': True,
27+
}

report_py3o/demo/report_py3o.xml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- Copyright 2016 ACSONE SA/NV
3+
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
4+
5+
<odoo>
6+
7+
<record id="res_users_report_py3o" model="ir.actions.report.xml">
8+
<field name="name">Py3o Demo Report</field>
9+
<field name="type">ir.actions.report.xml</field>
10+
<field name="model">res.users</field>
11+
<field name="report_name">py3o_user_info</field>
12+
<field name="report_type">py3o</field>
13+
<field name="py3o_filetype">odt</field>
14+
<field name="py3o_is_local_fusion" eval="1"/>
15+
<field name="py3o_filetype">odt</field>
16+
<field name="module">report_py3o</field>
17+
<field name="py3o_template_fallback">demo/res_user.odt</field>
18+
</record>
19+
20+
<record id="res_users_report_py3o_print_action" model="ir.values">
21+
<field eval="'action'" name="key" />
22+
<field eval="'client_print_multi'" name="key2" />
23+
<field name="model">res.users</field>
24+
<field name="name">Py3o Demo Report</field>
25+
<field eval="'ir.actions.report.xml,'+str(res_users_report_py3o)" name="value" />
26+
</record>
27+
28+
</odoo>

report_py3o/demo/res_user.odt

8.47 KB
Binary file not shown.

0 commit comments

Comments
 (0)