Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 32 additions & 36 deletions report_py3o/README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

==================
Py3o Report Engine
==================
Expand All @@ -17,7 +13,7 @@ Py3o Report Engine
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Freporting--engine-lightgray.png?logo=github
Expand All @@ -35,29 +31,29 @@ Py3o Report Engine
The py3o reporting engine is a reporting engine for Odoo based on
[Libreoffice](http://www.libreoffice.org/):

- 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 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 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!
- 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.
- 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).
- 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!
- 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.
- 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 module *report_py3o* is the base module for the Py3o reporting
engine. If used alone, it will spawn a libreoffice process for each ODT
Expand Down Expand Up @@ -183,9 +179,9 @@ project
Known issues / Roadmap
======================

- generate barcode ?
- add more detailed example in demo file to showcase features
- add migration guide aeroo -> py3o
- generate barcode ?
- add more detailed example in demo file to showcase features
- add migration guide aeroo -> py3o

Bug Tracker
===========
Expand All @@ -209,14 +205,14 @@ Authors
Contributors
------------

- Florent Aide ([XCG Consulting](http://odoo.consulting/))
- Laurent Mignon <<[email protected]>>,
- Alexis de Lattre <<[email protected]>>,
- Guewen Baconnier <<[email protected]>>
- Omar Casti??eira <<[email protected]>>
- Holger Brunn <<[email protected]>>
- Phuc Tran Thanh <<[email protected]>>
- Souheil Bejaoui <<[email protected]>>,
- Florent Aide ([XCG Consulting](http://odoo.consulting/))
- Laurent Mignon <<[email protected]>>,
- Alexis de Lattre <<[email protected]>>,
- Guewen Baconnier <<[email protected]>>
- Omar Casti??eira <<[email protected]>>
- Holger Brunn <<[email protected]>>
- Phuc Tran Thanh <<[email protected]>>
- Souheil Bejaoui <<[email protected]>>,

Maintainers
-----------
Expand Down
2 changes: 1 addition & 1 deletion report_py3o/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"website": "https://github.com/OCA/reporting-engine",
"depends": ["web"],
"external_dependencies": {
"python": ["py3o.template", "py3o.formats"],
"python": ["py3o.template", "py3o.formats", "pypdf"],
"deb": ["libreoffice"],
},
"assets": {
Expand Down
4 changes: 0 additions & 4 deletions report_py3o/models/_py3o_parser_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ def _format_lang(
lang_code=False,
digits=None,
grouping=True,
monetary=False,
dp=False,
currency_obj=False,
no_break_space=True,
Expand All @@ -73,7 +72,6 @@ def _format_lang(
value,
digits=digits,
grouping=grouping,
monetary=monetary,
dp=dp,
currency_obj=currency_obj,
)
Expand Down Expand Up @@ -104,7 +102,6 @@ def _old_format_lang(
date=False,
date_time=False,
grouping=True,
monetary=False,
dp=False,
currency_obj=False,
):
Expand All @@ -130,7 +127,6 @@ def _old_format_lang(
value,
digits=digits,
grouping=grouping,
monetary=monetary,
dp=dp,
currency_obj=currency_obj,
no_break_space=True,
Expand Down
2 changes: 1 addition & 1 deletion report_py3o/models/py3o_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def _create_single_report(self, model_instance, data):
"""This function to generate our py3o report"""
self.ensure_one()
result_fd, result_path = tempfile.mkstemp(
suffix=".ods", prefix="p3o.report.tmp."
suffix=".odt", prefix="py3o.report.tmp."
)
tmpl_data = self.get_template(model_instance)

Expand Down
42 changes: 18 additions & 24 deletions report_py3o/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>README.rst</title>
<title>Py3o Report Engine</title>
<style type="text/css">

/*
Expand Down Expand Up @@ -360,38 +360,33 @@
</style>
</head>
<body>
<div class="document">
<div class="document" id="py3o-report-engine">
<h1 class="title">Py3o Report Engine</h1>


<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
</a>
<div class="section" id="py3o-report-engine">
<h1>Py3o Report Engine</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:dd09d33437e18bcf07a71714ec039c5a9795fbaa3d034b89a60a1d7d9f57ddb6
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/reporting-engine/tree/18.0/report_py3o"><img alt="OCA/reporting-engine" src="https://img.shields.io/badge/github-OCA%2Freporting--engine-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/reporting-engine-18-0/reporting-engine-18-0-report_py3o"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/reporting-engine&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/reporting-engine/tree/18.0/report_py3o"><img alt="OCA/reporting-engine" src="https://img.shields.io/badge/github-OCA%2Freporting--engine-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/reporting-engine-18-0/reporting-engine-18-0-report_py3o"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/reporting-engine&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>The py3o reporting engine is a reporting engine for Odoo based on
[Libreoffice](<a class="reference external" href="http://www.libreoffice.org/">http://www.libreoffice.org/</a>):</p>
<ul class="simple">
<li>the report is created with Libreoffice (ODT or ODS),</li>
<li>the report is stored on the server in OpenDocument format (.odt or
.ods file)</li>
<li>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.)</li>
<li>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.)</li>
</ul>
<p>The key advantages of a Libreoffice based reporting engine are:</p>
<ul class="simple">
<li>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!</li>
<li>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
<li>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.</li>
Expand Down Expand Up @@ -436,15 +431,15 @@ <h1>Py3o Report Engine</h1>
</ul>
</div>
<div class="section" id="installation">
<h2><a class="toc-backref" href="#toc-entry-1">Installation</a></h2>
<h1><a class="toc-backref" href="#toc-entry-1">Installation</a></h1>
<p>Install the required python libs:</p>
<p>:literal:`` pip install py3o.template pip install py3o.formats``</p>
<p>To allow the conversion of ODT or ODS reports to other formats (PDF,
DOC, DOCX, etc.), install libreoffice:</p>
<p>:literal:`` apt-get –no-install-recommends install libreoffice``</p>
</div>
<div class="section" id="configuration">
<h2><a class="toc-backref" href="#toc-entry-2">Configuration</a></h2>
<h1><a class="toc-backref" href="#toc-entry-2">Configuration</a></h1>
<p>For example, to replace the native invoice report by a custom py3o
report, add the following XML file in your custom module:</p>
<p>:literal:`` &lt;?xml version=”1.0” encoding=”utf-8”?&gt; &lt;odoo&gt; &lt;record id=”account.account_invoices” model=”ir.actions.report”&gt; &lt;field name=”report_type”&gt;py3o&lt;/field&gt; &lt;field name=”py3o_filetype”&gt;odt&lt;/field&gt; &lt;field name=”module”&gt;my_custom_module_base&lt;/field&gt; &lt;field name=”py3o_template_fallback”&gt;report/account_invoice.odt&lt;/field&gt; &lt;/record&gt; &lt;/odoo&gt;``</p>
Expand Down Expand Up @@ -473,7 +468,7 @@ <h2><a class="toc-backref" href="#toc-entry-2">Configuration</a></h2>
will be started in $file’s directory.</p>
</div>
<div class="section" id="usage">
<h2><a class="toc-backref" href="#toc-entry-3">Usage</a></h2>
<h1><a class="toc-backref" href="#toc-entry-3">Usage</a></h1>
<p>The templating language is [extensively
documented](<a class="reference external" href="http://py3otemplate.readthedocs.io/en/latest/templating.html">http://py3otemplate.readthedocs.io/en/latest/templating.html</a>),
the records are exposed in libreoffice as objects, on which you can also
Expand Down Expand Up @@ -503,32 +498,32 @@ <h2><a class="toc-backref" href="#toc-entry-3">Usage</a></h2>
[odoo-py3o-report-templates](<a class="reference external" href="https://github.com/akretion/odoo-py3o-report-templates">https://github.com/akretion/odoo-py3o-report-templates</a>).</p>
</div>
<div class="section" id="known-issues-roadmap">
<h2><a class="toc-backref" href="#toc-entry-4">Known issues / Roadmap</a></h2>
<h1><a class="toc-backref" href="#toc-entry-4">Known issues / Roadmap</a></h1>
<ul class="simple">
<li>generate barcode ?</li>
<li>add more detailed example in demo file to showcase features</li>
<li>add migration guide aeroo -&gt; py3o</li>
</ul>
</div>
<div class="section" id="bug-tracker">
<h2><a class="toc-backref" href="#toc-entry-5">Bug Tracker</a></h2>
<h1><a class="toc-backref" href="#toc-entry-5">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/reporting-engine/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/reporting-engine/issues/new?body=module:%20report_py3o%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h2><a class="toc-backref" href="#toc-entry-6">Credits</a></h2>
<h1><a class="toc-backref" href="#toc-entry-6">Credits</a></h1>
<div class="section" id="authors">
<h3><a class="toc-backref" href="#toc-entry-7">Authors</a></h3>
<h2><a class="toc-backref" href="#toc-entry-7">Authors</a></h2>
<ul class="simple">
<li>XCG Consulting</li>
<li>ACSONE SA/NV</li>
</ul>
</div>
<div class="section" id="contributors">
<h3><a class="toc-backref" href="#toc-entry-8">Contributors</a></h3>
<h2><a class="toc-backref" href="#toc-entry-8">Contributors</a></h2>
<ul class="simple">
<li>Florent Aide ([XCG Consulting](<a class="reference external" href="http://odoo.consulting/">http://odoo.consulting/</a>))</li>
<li>Laurent Mignon &lt;&lt;<a class="reference external" href="mailto:laurent.mignon&#64;acsone.eu">laurent.mignon&#64;acsone.eu</a>&gt;&gt;,</li>
Expand All @@ -541,7 +536,7 @@ <h3><a class="toc-backref" href="#toc-entry-8">Contributors</a></h3>
</ul>
</div>
<div class="section" id="maintainers">
<h3><a class="toc-backref" href="#toc-entry-9">Maintainers</a></h3>
<h2><a class="toc-backref" href="#toc-entry-9">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
Expand All @@ -554,6 +549,5 @@ <h3><a class="toc-backref" href="#toc-entry-9">Maintainers</a></h3>
</div>
</div>
</div>
</div>
</body>
</html>
27 changes: 11 additions & 16 deletions report_py3o/tests/test_report_py3o.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,7 @@
from importlib.resources import as_file, files
from unittest import mock

from PyPDF2 import PdfFileWriter

try:
# For PyPDF2 <= 1.26.0
from PyPDF2.pdf import PageObject
except ImportError:
# For PyPDF2 >= 2.0.0
from PyPDF2 import PageObject
from pypdf import PageObject, PdfWriter

from odoo import tools
from odoo.exceptions import ValidationError
Expand Down Expand Up @@ -50,12 +43,14 @@ def temporary_copy(path):


class TestReportPy3o(TransactionCase):
def setUp(self):
super().setUp()
self.env.user.image_1920 = PNG
self.report = self.env.ref("report_py3o.res_users_report_py3o")
self.py3o_report = self.env["py3o.report"].create(
{"ir_actions_report_id": self.report.id}
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True))
cls.env.user.image_1920 = PNG
cls.report = cls.env.ref("report_py3o.res_users_report_py3o")
cls.py3o_report = cls.env["py3o.report"].create(
{"ir_actions_report_id": cls.report.id}
)

def test_required_py3_filetype(self):
Expand Down Expand Up @@ -107,8 +102,8 @@ def test_reports_merge_pdf(self):
reports_path = []
for _i in range(0, 3):
result = tempfile.mktemp(".txt")
writer = PdfFileWriter()
writer.addPage(PageObject.createBlankPage(width=100, height=100))
writer = PdfWriter()
writer.add_page(PageObject.create_blank_page(width=100, height=100))
with open(result, "wb") as fp:
writer.write(fp)
reports_path.append(result)
Expand Down
Loading