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.

244 lines
10 KiB

  1. ==================
  2. Py3o Report Engine
  3. ==================
  4. .. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  5. !! This file is generated by oca-gen-addon-readme !!
  6. !! changes will be overwritten. !!
  7. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  8. .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
  9. :target: https://odoo-community.org/page/development-status
  10. :alt: Beta
  11. .. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
  12. :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
  13. :alt: License: AGPL-3
  14. .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Freporting--engine-lightgray.png?logo=github
  15. :target: https://github.com/OCA/reporting-engine/tree/12.0/report_py3o
  16. :alt: OCA/reporting-engine
  17. .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
  18. :target: https://translation.odoo-community.org/projects/reporting-engine-12-0/reporting-engine-12-0-report_py3o
  19. :alt: Translate me on Weblate
  20. .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
  21. :target: https://runbot.odoo-community.org/runbot/143/12.0
  22. :alt: Try me on Runbot
  23. |badge1| |badge2| |badge3| |badge4| |badge5|
  24. The py3o reporting engine is a reporting engine for Odoo based on `Libreoffice <http://www.libreoffice.org/>`_:
  25. * the report is created with Libreoffice (ODT or ODS),
  26. * the report is stored on the server in OpenDocument format (.odt or .ods file)
  27. * 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.)
  28. The key advantages of a Libreoffice based reporting engine are:
  29. * no need to be a developer to create or modify a report: the report is created and modified with Libreoffice. So this reporting engine has a full WYSIWYG report development tool!
  30. * 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, also some print peculiarities (backgrounds, margin boxes) are not very well supported by the HTML/CSS based solutions.
  31. * 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.
  32. * Easy development of spreadsheet reports in ODS format (XLS output possible).
  33. This module *report_py3o* is the base module for the Py3o reporting engine. If used alone, it will spawn a libreoffice process for each ODT to PDF (or ODT to DOCX, ..) document conversion. This is slow and can become a problem if you have a lot of reports to convert from ODT to another format. In this case, you should consider the additionnal module *report_py3o_fusion_server* which is designed to work with a libreoffice daemon. With *report_py3o_fusion_server*, the technical environnement is more complex to setup because you have to install additionnal software components and run 2 daemons, but you have much better performances and you can configure the libreoffice PDF export options in Odoo (allows to generate PDF forms, PDF/A documents, password-protected PDFs, watermarked PDFs, etc.).
  34. This reporting engine is an alternative to `Aeroo <https://github.com/aeroo-community/aeroo_reports>`_: these two reporting engines have similar features but their implementation is entirely different. You cannot use aeroo templates as drop in replacement though, you'll have to change a few details.
  35. **Table of contents**
  36. .. contents::
  37. :local:
  38. Installation
  39. ============
  40. Install the required python libs:
  41. .. code::
  42. pip install py3o.template
  43. pip install py3o.formats
  44. To allow the conversion of ODT or ODS reports to other formats (PDF, DOC, DOCX, etc.), install libreoffice:
  45. .. code::
  46. apt-get --no-install-recommends install libreoffice
  47. Configuration
  48. =============
  49. For example, to replace the native invoice report by a custom py3o report, add the following XML file in your custom module:
  50. .. code::
  51. <?xml version="1.0" encoding="utf-8"?>
  52. <odoo>
  53. <record id="account.account_invoices" model="ir.actions.report">
  54. <field name="report_type">py3o</field>
  55. <field name="py3o_filetype">odt</field>
  56. <field name="module">my_custom_module_base</field>
  57. <field name="py3o_template_fallback">report/account_invoice.odt</field>
  58. </record>
  59. </odoo>
  60. 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*.
  61. It's also possible to reference a template located in a trusted path of your
  62. Odoo server. In this case you must let the *module* entry empty and specify
  63. the path to the template as *py3o_template_fallback*.
  64. .. code::
  65. <?xml version="1.0" encoding="utf-8"?>
  66. <odoo>
  67. <record id="account.account_invoices" model="ir.actions.report">
  68. <field name="report_type">py3o</field>
  69. <field name="py3o_filetype">odt</field>
  70. <field name="py3o_template_fallback">/odoo/templates/py3o/report/account_invoice.odt</field>
  71. </record>
  72. </odoo>
  73. Moreover, you must also modify the Odoo server configuration file to declare
  74. the allowed root directory for your py3o templates. Only templates located
  75. into this directory can be loaded by py3o report.
  76. .. code::
  77. [options]
  78. ...
  79. [report_py3o]
  80. root_tmpl_path=/odoo/templates/py3o
  81. If you want an invoice in PDF format instead of ODT format, the XML file should look like:
  82. .. code::
  83. <?xml version="1.0" encoding="utf-8"?>
  84. <odoo>
  85. <record id="account.account_invoices" model="ir.actions.report">
  86. <field name="report_type">py3o</field>
  87. <field name="py3o_filetype">pdf</field>
  88. <field name="module">my_custom_module_base</field>
  89. <field name="py3o_template_fallback">report/account_invoice.odt</field>
  90. </record>
  91. </odoo>
  92. If you want to add a new py3o PDF report (and not replace a native report), the XML file should look like this:
  93. .. code::
  94. <?xml version="1.0" encoding="utf-8"?>
  95. <odoo>
  96. <record id="partner_summary_report" model="ir.actions.report">
  97. <field name="name">Partner Summary</field>
  98. <field name="model">res.partner</field>
  99. <field name="report_name">res.partner.summary</field>
  100. <field name="report_type">py3o</field>
  101. <field name="py3o_filetype">pdf</field>
  102. <field name="module">my_custom_module_base</field>
  103. <field name="py3o_template_fallback">report/partner_summary.odt</field>
  104. <!-- Add entry in "Print" drop-down list -->
  105. <field name="binding_type">report</field>
  106. <field name="binding_model_id" ref="base.model_res_partner"/>
  107. </record>
  108. </odoo>
  109. Configuration parameters
  110. ~~~~~~~~~~~~~~~~~~~~~~~~
  111. py3o.conversion_command
  112. The command to be used to run the conversion, ``libreoffice`` by default. If you change this, whatever you set here must accept the parameters ``--headless --convert-to $ext $file`` and put the resulting file into ``$file``'s directory with extension ``$ext``. The command will be started in ``$file``'s directory.
  113. Usage
  114. =====
  115. The templating language is `extensively documented <http://py3otemplate.readthedocs.io/en/latest/templating.html>`_, the records are exposed in libreoffice as ``objects``, on which you can also call functions.
  116. Available functions and objects
  117. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  118. user
  119. Browse record of current user
  120. lang
  121. The user's company's language as string (ISO code)
  122. b64decode
  123. ``base64.b64decode``
  124. format_multiline_value(string)
  125. Generate the ODF equivalent of ``<br/>`` and ``&nbsp;`` for multiline fields (ODF is XML internally, so those would be skipped otherwise)
  126. html_sanitize(string)
  127. Sanitize HTML string
  128. time
  129. Python's ``time`` module
  130. display_address(partner)
  131. Return a formatted string of the partner's address
  132. o_format_lang(value, lang_code=False, digits=None, grouping=True, monetary=False, dp=False, currency_obj=False, no_break_space=True)
  133. Return a formatted numeric or monetary value according to the context language and timezone
  134. o_format_date(value, lang_code=False, date_format=False)
  135. Return a formatted date or time value according to the context language and timezone
  136. Sample report templates
  137. ~~~~~~~~~~~~~~~~~~~~~~~
  138. Sample py3o report templates for the main Odoo native reports (invoice, sale order, purchase order, picking, etc.) are available on the Github project `odoo-py3o-report-templates <https://github.com/akretion/odoo-py3o-report-templates>`_.
  139. Known issues / Roadmap
  140. ======================
  141. * generate barcode ?
  142. * add more detailed example in demo file to showcase features
  143. * add migration guide aeroo -> py3o
  144. Bug Tracker
  145. ===========
  146. Bugs are tracked on `GitHub Issues <https://github.com/OCA/reporting-engine/issues>`_.
  147. In case of trouble, please check there if your issue has already been reported.
  148. If you spotted it first, help us smashing it by providing a detailed and welcomed
  149. `feedback <https://github.com/OCA/reporting-engine/issues/new?body=module:%20report_py3o%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
  150. Do not contact contributors directly about support or help with technical issues.
  151. Credits
  152. =======
  153. Authors
  154. ~~~~~~~
  155. * XCG Consulting
  156. * ACSONE SA/NV
  157. Contributors
  158. ~~~~~~~~~~~~
  159. * Florent Aide (`XCG Consulting <http://odoo.consulting/>`_)
  160. * Laurent Mignon <laurent.mignon@acsone.eu>,
  161. * Alexis de Lattre <alexis.delattre@akretion.com>,
  162. * Guewen Baconnier <guewen.baconnier@camptocamp.com>
  163. * Omar Castiñeira <omar@comunitea.com>
  164. * Holger Brunn <hbrunn@therp.nl>
  165. Maintainers
  166. ~~~~~~~~~~~
  167. This module is maintained by the OCA.
  168. .. image:: https://odoo-community.org/logo.png
  169. :alt: Odoo Community Association
  170. :target: https://odoo-community.org
  171. OCA, or the Odoo Community Association, is a nonprofit organization whose
  172. mission is to support the collaborative development of Odoo features and
  173. promote its widespread use.
  174. This module is part of the `OCA/reporting-engine <https://github.com/OCA/reporting-engine/tree/12.0/report_py3o>`_ project on GitHub.
  175. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.