OCA reporting engine fork for dev and update.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

227 lines
8.3 KiB

8 years ago
  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. Report Py3o
  6. ===========
  7. The py3o reporting engine is a reporting engine for Odoo based on `Libreoffice <http://www.libreoffice.org/>`_:
  8. * the report is created with Libreoffice (ODT or ODS),
  9. * the report is stored on the server in OpenDocument format (.odt or .ods file)
  10. * 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.)
  11. The key advantages of a Libreoffice-based reporting engine are:
  12. * 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!
  13. * 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.
  14. * 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.
  15. * Easy development of spreadsheet reports in ODS format (XLS output possible).
  16. 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.
  17. Installation
  18. ============
  19. You must install 2 additionnal python libs:
  20. .. code::
  21. pip install py3o.template
  22. pip install py3o.formats
  23. 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:
  24. * `Py3o Fusion server <https://bitbucket.org/faide/py3o.fusion>`_,
  25. * `Py3o render server <https://bitbucket.org/faide/py3o.renderserver>`_,
  26. * a Java Runtime Environment (JRE), which can be OpenJDK,
  27. * Libreoffice started in the background in headless mode,
  28. * the Java driver for Libreoffice (Juno).
  29. 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.
  30. 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.
  31. Installation of py3o.fusion:
  32. .. code::
  33. pip install py3o.fusion
  34. pip install service-identity
  35. Installation of py3o.renderserver:
  36. .. code::
  37. pip install py3o.renderserver
  38. Installation of Libreoffice and JRE on Debian/Ubuntu:
  39. .. code::
  40. sudo apt-get install default-jre ure libreoffice-java-common libreoffice-writer
  41. 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:
  42. .. code::
  43. sudo apt-get install fonts-symbola
  44. At the end, with the dependencies, you should have the following py3o python libs:
  45. .. code::
  46. % pip freeze | grep py3o
  47. py3o.formats==0.3
  48. py3o.fusion==0.8.6
  49. py3o.renderclient==0.2
  50. py3o.renderers.juno==0.8
  51. py3o.renderserver==0.5.1
  52. py3o.template==0.9.11
  53. py3o.types==0.1.1
  54. Start the Py3o Fusion server:
  55. .. code::
  56. start-py3o-fusion --debug -s localhost
  57. Start the Py3o render server:
  58. .. code::
  59. 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
  60. On the output of the Py3o render server, the first line looks like:
  61. .. code::
  62. 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
  63. 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.
  64. 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.*.
  65. Configuration
  66. =============
  67. For example, to replace the native invoice report by a custom py3o report, add the following XML file in your custom module:
  68. .. code::
  69. <?xml version="1.0" encoding="utf-8"?>
  70. <odoo>
  71. <record id="account.account_invoices" model="ir.actions.report.xml">
  72. <field name="report_type">py3o</field>
  73. <field name="py3o_filetype">odt</field>
  74. <field name="module">my_custom_module_base</field>
  75. <field name="py3o_template_fallback">report/account_invoice.odt</field>
  76. </record>
  77. </odoo>
  78. 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*.
  79. If you want an invoice in PDF format instead of ODT format, the XML file should look like:
  80. .. code::
  81. <?xml version="1.0" encoding="utf-8"?>
  82. <odoo>
  83. <record id="local_py3o_server" model="py3o.server">
  84. <field name="url">http://localhost:8765/form</field>
  85. </record>
  86. <record id="account.account_invoices" model="ir.actions.report.xml">
  87. <field name="report_type">py3o</field>
  88. <field name="py3o_filetype">pdf</field>
  89. <field name="py3o_server_id" ref="local_py3o_server"/>
  90. <field name="module">my_custom_module_base</field>
  91. <field name="py3o_template_fallback">report/account_invoice.odt</field>
  92. </record>
  93. </odoo>
  94. If you want to add a new py3o PDF report (and not replace a native report), the XML file should look like this:
  95. .. code::
  96. <?xml version="1.0" encoding="utf-8"?>
  97. <odoo>
  98. <record id="local_py3o_server" model="py3o.server">
  99. <field name="url">http://localhost:8765/form</field>
  100. </record>
  101. <record id="partner_summary_report" model="ir.actions.report.xml">
  102. <field name="name">Partner Summary</field>
  103. <field name="model">res.partner</field>
  104. <field name="report_name">res.partner.summary</field>
  105. <field name="report_type">py3o</field>
  106. <field name="py3o_filetype">pdf</field>
  107. <field name="py3o_server_id" ref="local_py3o_server"/>
  108. <field name="module">my_custom_module_base</field>
  109. <field name="py3o_template_fallback">report/partner_summary.odt</field>
  110. </record>
  111. <!-- Add entry in "Print" drop-down list -->
  112. <record id="button_partner_summary_report" model="ir.values">
  113. <field name="key2">client_print_multi</field>
  114. <field name="model">res.partner</field>
  115. <field name="name">Partner Summary</field>
  116. <field name="value" eval="'ir.actions.report.xml,%d'%partner_summary_report" />
  117. </record>
  118. </odoo>
  119. Usage
  120. =====
  121. .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
  122. :alt: Try me on Runbot
  123. :target: https://runbot.odoo-community.org/runbot/143/10.0
  124. Known issues / Roadmap
  125. ======================
  126. * generate barcode ?
  127. Bug Tracker
  128. ===========
  129. Bugs are tracked on `GitHub Issues
  130. <https://github.com/OCA/reporting-engine/issues>`_. In case of trouble, please
  131. check there if your issue has already been reported. If you spotted it first,
  132. help us smashing it by providing a detailed and welcomed feedback.
  133. Credits
  134. =======
  135. Contributors
  136. ------------
  137. * Florent Aide (`XCG Consulting <http://odoo.consulting/>`_)
  138. * Laurent Mignon <laurent.mignon@acsone.eu>,
  139. * Alexis de Lattre <alexis.delattre@akretion.com>,
  140. Maintainer
  141. ----------
  142. .. image:: https://odoo-community.org/logo.png
  143. :alt: Odoo Community Association
  144. :target: https://odoo-community.org
  145. This module is maintained by the OCA.
  146. OCA, or the Odoo Community Association, is a nonprofit organization whose
  147. mission is to support the collaborative development of Odoo features and
  148. promote its widespread use.
  149. To contribute to this module, please visit https://odoo-community.org.