Skip to content

Commit

Permalink
Merge pull request #717 from OCA/16.0
Browse files Browse the repository at this point in the history
Syncing from upstream OCA/reporting-engine (16.0)
  • Loading branch information
bt-admin authored Sep 6, 2024
2 parents b0ca5c1 + 279d873 commit a696955
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ addon | version | maintainers | summary
[report_display_name_in_footer](report_display_name_in_footer/) | 16.0.1.1.0 | [![Shide](https://github.com/Shide.png?size=30px)](https://github.com/Shide) [![rafaelbn](https://github.com/rafaelbn.png?size=30px)](https://github.com/rafaelbn) | Show document name in report footer
[report_generate_helper](report_generate_helper/) | 16.0.1.0.0 | | Helper to easily generate report
[report_label](report_label/) | 16.0.1.0.1 | [![ivantodorovich](https://github.com/ivantodorovich.png?size=30px)](https://github.com/ivantodorovich) | Print configurable self-adhesive labels reports
[report_py3o](report_py3o/) | 16.0.1.0.3 | | Reporting engine based on Libreoffice (ODT -> ODT, ODT -> PDF, ODT -> DOC, ODT -> DOCX, ODS -> ODS, etc.)
[report_py3o](report_py3o/) | 16.0.1.0.4 | | Reporting engine based on Libreoffice (ODT -> ODT, ODT -> PDF, ODT -> DOC, ODT -> DOCX, ODS -> ODS, etc.)
[report_py3o_fusion_server](report_py3o_fusion_server/) | 16.0.1.0.0 | | Let the fusion server handle format conversion.
[report_qr](report_qr/) | 16.0.1.0.0 | | Web QR Manager
[report_qweb_decimal_place](report_qweb_decimal_place/) | 16.0.1.0.0 | | Report Qweb Decimal Place
Expand Down
2 changes: 1 addition & 1 deletion report_py3o/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Py3o Report Engine
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:46cf2061265682b6f8bd2365da18c060ac2f7e0b45382e21405d176c8abf3cda
!! source digest: sha256:6475c7e18340a01f1070b14e0c403646da2a1e1381b73969ba16b91c163d4db7
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down
2 changes: 1 addition & 1 deletion report_py3o/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "Py3o Report Engine",
"summary": "Reporting engine based on Libreoffice (ODT -> ODT, "
"ODT -> PDF, ODT -> DOC, ODT -> DOCX, ODS -> ODS, etc.)",
"version": "16.0.1.0.3",
"version": "16.0.1.0.4",
"category": "Reporting",
"license": "AGPL-3",
"author": "XCG Consulting, ACSONE SA/NV, Odoo Community Association (OCA)",
Expand Down
32 changes: 16 additions & 16 deletions report_py3o/models/py3o_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,16 +320,14 @@ def _get_or_create_single_report(

def _zip_results(self, reports_path):
self.ensure_one()
zfname_prefix = self.ir_actions_report_id.name
fd, result_path = tempfile.mkstemp(suffix="zip", prefix="py3o-zip-result")
os.close(fd)
with ZipFile(result_path, "w", ZIP_DEFLATED) as zf:
cpt = 0
for report in reports_path:
fname = "%s_%d.%s" % (zfname_prefix, cpt, report.split(".")[-1])
for report_instance, report in reports_path.items():
fname = self.ir_actions_report_id.gen_report_download_filename(
report_instance.ids, {}
)
zf.write(report, fname)

cpt += 1
return result_path

@api.model
Expand All @@ -353,12 +351,13 @@ def _merge_pdf(self, reports_path):
def _merge_results(self, reports_path):
self.ensure_one()
filetype = self.ir_actions_report_id.py3o_filetype
path_list = list(reports_path.values())
if not reports_path:
return False, False
if len(reports_path) == 1:
return reports_path[0], filetype
return path_list[0], filetype
if filetype == formats.FORMAT_PDF:
return self._merge_pdf(reports_path), formats.FORMAT_PDF
return self._merge_pdf(path_list), formats.FORMAT_PDF
else:
return self._zip_results(reports_path), "zip"

Expand All @@ -374,22 +373,23 @@ def _cleanup_tempfiles(self, temporary_files):
def create_report(self, res_ids, data):
"""Override this function to handle our py3o report"""
model_instances = self.env[self.ir_actions_report_id.model].browse(res_ids)
reports_path = []
reports_path = {}
if len(res_ids) > 1 and self.ir_actions_report_id.py3o_multi_in_one:
reports_path.append(self._create_single_report(model_instances, data))
reports_path[model_instances] = self._create_single_report(
model_instances, data
)
else:
existing_reports_attachment = self.ir_actions_report_id._get_attachments(
res_ids
)
for model_instance in model_instances:
reports_path.append(
self._get_or_create_single_report(
model_instance, data, existing_reports_attachment
)
reports_path[model_instance] = self._get_or_create_single_report(
model_instance, data, existing_reports_attachment
)

result_path, filetype = self._merge_results(reports_path)
reports_path.append(result_path)
cleanup_path = list(reports_path.values())
cleanup_path.append(result_path)

# Here is a little joke about Odoo
# we do all the generation process using files to avoid memory
Expand All @@ -398,5 +398,5 @@ def create_report(self, res_ids, data):

with open(result_path, "r+b") as fd:
res = fd.read()
self._cleanup_tempfiles(set(reports_path))
self._cleanup_tempfiles(set(cleanup_path))
return res, filetype
2 changes: 1 addition & 1 deletion report_py3o/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Py3o Report Engine</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:46cf2061265682b6f8bd2365da18c060ac2f7e0b45382e21405d176c8abf3cda
!! source digest: sha256:6475c7e18340a01f1070b14e0c403646da2a1e1381b73969ba16b91c163d4db7
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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/16.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-16-0/reporting-engine-16-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=16.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 <a class="reference external" href="http://www.libreoffice.org/">Libreoffice</a>:</p>
Expand Down

0 comments on commit a696955

Please sign in to comment.