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.

208 lines
7.5 KiB

  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 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!
  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, also some print peculiarities (backgrounds, margin boxes) are not very well supported by the HTML/CSS based solutions.
  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 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.
  17. Installation
  18. ============
  19. Install the required 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.), install libreoffice:
  24. .. code::
  25. apt-get --no-install-recommends install libreoffice
  26. Configuration
  27. =============
  28. For example, to replace the native invoice report by a custom py3o report, add the following XML file in your custom module:
  29. .. code::
  30. <?xml version="1.0" encoding="utf-8"?>
  31. <odoo>
  32. <record id="account.account_invoices" model="ir.actions.report.xml">
  33. <field name="report_type">py3o</field>
  34. <field name="py3o_filetype">odt</field>
  35. <field name="module">my_custom_module_base</field>
  36. <field name="py3o_template_fallback">report/account_invoice.odt</field>
  37. </record>
  38. </odoo>
  39. 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*.
  40. It's also possible to reference a template located in a trusted path of your
  41. Odoo server. In this case you must let the *module* entry empty and specify
  42. the path to the template as *py3o_template_fallback*.
  43. .. code::
  44. <?xml version="1.0" encoding="utf-8"?>
  45. <odoo>
  46. <record id="account.account_invoices" model="ir.actions.report.xml">
  47. <field name="report_type">py3o</field>
  48. <field name="py3o_filetype">odt</field>
  49. <field name="py3o_template_fallback">/odoo/templates/py3o/report/account_invoice.odt</field>
  50. </record>
  51. </odoo>
  52. Moreover you must also modify the odoo server configuration file to declare
  53. the allowed root directory for your py3o templates. Only templates located
  54. into this directory can be loaded by py3o report.
  55. .. code::
  56. [options]
  57. ...
  58. [report_py3o]
  59. root_tmpl_path=/odoo/templates/py3o
  60. If you want an invoice in PDF format instead of ODT format, the XML file should look like:
  61. .. code::
  62. <?xml version="1.0" encoding="utf-8"?>
  63. <odoo>
  64. <record id="account.account_invoices" model="ir.actions.report.xml">
  65. <field name="report_type">py3o</field>
  66. <field name="py3o_filetype">pdf</field>
  67. <field name="module">my_custom_module_base</field>
  68. <field name="py3o_template_fallback">report/account_invoice.odt</field>
  69. </record>
  70. </odoo>
  71. If you want to add a new py3o PDF report (and not replace a native report), the XML file should look like this:
  72. .. code::
  73. <?xml version="1.0" encoding="utf-8"?>
  74. <odoo>
  75. <record id="partner_summary_report" model="ir.actions.report.xml">
  76. <field name="name">Partner Summary</field>
  77. <field name="model">res.partner</field>
  78. <field name="report_name">res.partner.summary</field>
  79. <field name="report_type">py3o</field>
  80. <field name="py3o_filetype">pdf</field>
  81. <field name="module">my_custom_module_base</field>
  82. <field name="py3o_template_fallback">report/partner_summary.odt</field>
  83. </record>
  84. <!-- Add entry in "Print" drop-down list -->
  85. <record id="button_partner_summary_report" model="ir.values">
  86. <field name="key2">client_print_multi</field>
  87. <field name="model">res.partner</field>
  88. <field name="name">Partner Summary</field>
  89. <field name="value" eval="'ir.actions.report.xml,%d'%partner_summary_report" />
  90. </record>
  91. </odoo>
  92. Configuration parameters
  93. ------------------------
  94. py3o.conversion_command
  95. 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.
  96. Usage
  97. =====
  98. .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
  99. :alt: Try me on Runbot
  100. :target: https://runbot.odoo-community.org/runbot/143/10.0
  101. 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.
  102. Available functions and objects
  103. -------------------------------
  104. user
  105. Browse record of current user
  106. lang
  107. The user's company's language as string (ISO code)
  108. b64decode
  109. ``base64.b64decode``
  110. format_multiline_value(string)
  111. Generate the ODF equivalent of ``<br/>`` and ``&nbsp;`` for multiline fields (ODF is XML internally, so those would be skipped otherwise)
  112. html_sanitize(string)
  113. Sanitize HTML string
  114. time
  115. Python's ``time`` module
  116. display_address(partner)
  117. Return a formatted string of the partner's address
  118. Known issues / Roadmap
  119. ======================
  120. * generate barcode ?
  121. * add more detailed example in demo file to showcase features
  122. * add migration guide aeroo -> py3o
  123. Bug Tracker
  124. ===========
  125. Bugs are tracked on `GitHub Issues
  126. <https://github.com/OCA/reporting-engine/issues>`_. In case of trouble, please
  127. check there if your issue has already been reported. If you spotted it first,
  128. help us smashing it by providing a detailed and welcomed feedback.
  129. Credits
  130. =======
  131. Contributors
  132. ------------
  133. * Florent Aide (`XCG Consulting <http://odoo.consulting/>`_)
  134. * Laurent Mignon <laurent.mignon@acsone.eu>,
  135. * Alexis de Lattre <alexis.delattre@akretion.com>,
  136. * Guewen Baconnier <guewen.baconnier@camptocamp.com>
  137. * Omar Castiñeira <omar@comunitea.com>
  138. * Holger Brunn <hbrunn@therp.nl>
  139. Maintainer
  140. ----------
  141. .. image:: https://odoo-community.org/logo.png
  142. :alt: Odoo Community Association
  143. :target: https://odoo-community.org
  144. This module is maintained by the OCA.
  145. OCA, or the Odoo Community Association, is a nonprofit organization whose
  146. mission is to support the collaborative development of Odoo features and
  147. promote its widespread use.
  148. To contribute to this module, please visit https://odoo-community.org.