[IMP] report_xlsx: pre-commit auto fixes
parent
dc48b19cff
commit
2381d65fb1
Binary file not shown.
|
@ -17,13 +17,13 @@ Base report xlsx
|
||||||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
||||||
:alt: License: AGPL-3
|
:alt: License: AGPL-3
|
||||||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Freporting--engine-lightgray.png?logo=github
|
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Freporting--engine-lightgray.png?logo=github
|
||||||
:target: https://github.com/OCA/reporting-engine/tree/16.0/report_xlsx
|
:target: https://github.com/OCA/reporting-engine/tree/17.0/report_xlsx
|
||||||
:alt: OCA/reporting-engine
|
:alt: OCA/reporting-engine
|
||||||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
|
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
|
||||||
:target: https://translation.odoo-community.org/projects/reporting-engine-16-0/reporting-engine-16-0-report_xlsx
|
:target: https://translation.odoo-community.org/projects/reporting-engine-17-0/reporting-engine-17-0-report_xlsx
|
||||||
:alt: Translate me on Weblate
|
:alt: Translate me on Weblate
|
||||||
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
|
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
|
||||||
:target: https://runboat.odoo-community.org/builds?repo=OCA/reporting-engine&target_branch=16.0
|
:target: https://runboat.odoo-community.org/builds?repo=OCA/reporting-engine&target_branch=17.0
|
||||||
:alt: Try me on Runboat
|
:alt: Try me on Runboat
|
||||||
|
|
||||||
|badge1| |badge2| |badge3| |badge4| |badge5|
|
|badge1| |badge2| |badge3| |badge4| |badge5|
|
||||||
|
@ -38,20 +38,27 @@ This module provides a basic report class to generate xlsx report.
|
||||||
Installation
|
Installation
|
||||||
============
|
============
|
||||||
|
|
||||||
Make sure you have ``xlsxwriter`` Python module installed::
|
Make sure you have ``xlsxwriter`` Python module installed:
|
||||||
|
|
||||||
|
::
|
||||||
|
|
||||||
$ pip3 install xlsxwriter
|
$ pip3 install xlsxwriter
|
||||||
|
|
||||||
For testing it is also necessary ``xlrd`` Python module installed::
|
For testing it is also necessary ``xlrd`` Python module installed:
|
||||||
|
|
||||||
|
::
|
||||||
|
|
||||||
$ pip3 install xlrd
|
$ pip3 install xlrd
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
=====
|
=====
|
||||||
|
|
||||||
An example of XLSX report for partners on a module called `module_name`:
|
An example of XLSX report for partners on a module called
|
||||||
|
\`module_name\`:
|
||||||
|
|
||||||
A python class ::
|
A python class :
|
||||||
|
|
||||||
|
::
|
||||||
|
|
||||||
from odoo import models
|
from odoo import models
|
||||||
|
|
||||||
|
@ -68,9 +75,12 @@ A python class ::
|
||||||
sheet.write(0, 0, obj.name, bold)
|
sheet.write(0, 0, obj.name, bold)
|
||||||
|
|
||||||
To manipulate the ``workbook`` and ``sheet`` objects, refer to the
|
To manipulate the ``workbook`` and ``sheet`` objects, refer to the
|
||||||
`documentation <http://xlsxwriter.readthedocs.org/>`_ of ``xlsxwriter``.
|
`documentation <http://xlsxwriter.readthedocs.org/>`__ of
|
||||||
|
``xlsxwriter``.
|
||||||
|
|
||||||
A report XML record ::
|
A report XML record :
|
||||||
|
|
||||||
|
::
|
||||||
|
|
||||||
<report
|
<report
|
||||||
id="partner_xlsx"
|
id="partner_xlsx"
|
||||||
|
@ -88,7 +98,7 @@ Bug Tracker
|
||||||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/reporting-engine/issues>`_.
|
Bugs are tracked on `GitHub Issues <https://github.com/OCA/reporting-engine/issues>`_.
|
||||||
In case of trouble, please check there if your issue has already been reported.
|
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
|
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
||||||
`feedback <https://github.com/OCA/reporting-engine/issues/new?body=module:%20report_xlsx%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
`feedback <https://github.com/OCA/reporting-engine/issues/new?body=module:%20report_xlsx%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||||
|
|
||||||
Do not contact contributors directly about support or help with technical issues.
|
Do not contact contributors directly about support or help with technical issues.
|
||||||
|
|
||||||
|
@ -96,27 +106,27 @@ Credits
|
||||||
=======
|
=======
|
||||||
|
|
||||||
Authors
|
Authors
|
||||||
~~~~~~~
|
-------
|
||||||
|
|
||||||
* ACSONE SA/NV
|
* ACSONE SA/NV
|
||||||
* Creu Blanca
|
* Creu Blanca
|
||||||
|
|
||||||
Contributors
|
Contributors
|
||||||
~~~~~~~~~~~~
|
------------
|
||||||
|
|
||||||
* Adrien Peiffer <adrien.peiffer@acsone.eu>
|
- Adrien Peiffer <adrien.peiffer@acsone.eu>
|
||||||
* S??bastien Alix <sebastien.alix@osiell.com>
|
- S??bastien Alix <sebastien.alix@osiell.com>
|
||||||
* St??phane Bidoul <stephane.bidoul@acsone.eu>
|
- St??phane Bidoul <stephane.bidoul@acsone.eu>
|
||||||
* Enric Tobella <etobella@creublanca.es>
|
- Enric Tobella <etobella@creublanca.es>
|
||||||
* Graeme Gellatly <gdgellatly@gmail.com>
|
- Graeme Gellatly <gdgellatly@gmail.com>
|
||||||
* Cristian Salamea <cs@prisehub.com>
|
- Cristian Salamea <cs@prisehub.com>
|
||||||
* Rod Schouteden <rod.schouteden@dynapps.be>
|
- Rod Schouteden <rod.schouteden@dynapps.be>
|
||||||
* Eugene Molotov <molotov@it-projects.info>
|
- Eugene Molotov <molotov@it-projects.info>
|
||||||
* Christopher Ormaza <chris.ormaza@forgeflow.com>
|
- Christopher Ormaza <chris.ormaza@forgeflow.com>
|
||||||
* Houz??fa Abbasbhay <houzefa.abba@xcg-consulting.fr>
|
- Houz??fa Abbasbhay <houzefa.abba@xcg-consulting.fr>
|
||||||
|
|
||||||
Maintainers
|
Maintainers
|
||||||
~~~~~~~~~~~
|
-----------
|
||||||
|
|
||||||
This module is maintained by the OCA.
|
This module is maintained by the OCA.
|
||||||
|
|
||||||
|
@ -128,6 +138,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||||
mission is to support the collaborative development of Odoo features and
|
mission is to support the collaborative development of Odoo features and
|
||||||
promote its widespread use.
|
promote its widespread use.
|
||||||
|
|
||||||
This module is part of the `OCA/reporting-engine <https://github.com/OCA/reporting-engine/tree/16.0/report_xlsx>`_ project on GitHub.
|
This module is part of the `OCA/reporting-engine <https://github.com/OCA/reporting-engine/tree/17.0/report_xlsx>`_ project on GitHub.
|
||||||
|
|
||||||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
||||||
|
|
|
@ -11,6 +11,8 @@ from odoo.http import (
|
||||||
content_disposition,
|
content_disposition,
|
||||||
request,
|
request,
|
||||||
route,
|
route,
|
||||||
|
)
|
||||||
|
from odoo.http import (
|
||||||
serialize_exception as _serialize_exception,
|
serialize_exception as _serialize_exception,
|
||||||
)
|
)
|
||||||
from odoo.tools import html_escape
|
from odoo.tools import html_escape
|
||||||
|
@ -69,8 +71,9 @@ class ReportController(ReportController):
|
||||||
url_decode(url.split("?")[1]).items()
|
url_decode(url.split("?")[1]).items()
|
||||||
) # decoding the args represented in JSON
|
) # decoding the args represented in JSON
|
||||||
if "context" in data:
|
if "context" in data:
|
||||||
context, data_context = json.loads(context or "{}"), json.loads(
|
context, data_context = (
|
||||||
data.pop("context")
|
json.loads(context or "{}"),
|
||||||
|
json.loads(data.pop("context")),
|
||||||
)
|
)
|
||||||
context = json.dumps({**context, **data_context})
|
context = json.dumps({**context, **data_context})
|
||||||
response = self.report_routes(
|
response = self.report_routes(
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
[build-system]
|
||||||
|
requires = ["whool"]
|
||||||
|
build-backend = "whool.buildapi"
|
|
@ -0,0 +1,10 @@
|
||||||
|
- Adrien Peiffer \<<adrien.peiffer@acsone.eu>\>
|
||||||
|
- S??bastien Alix \<<sebastien.alix@osiell.com>\>
|
||||||
|
- St??phane Bidoul \<<stephane.bidoul@acsone.eu>\>
|
||||||
|
- Enric Tobella \<<etobella@creublanca.es>\>
|
||||||
|
- Graeme Gellatly \<<gdgellatly@gmail.com>\>
|
||||||
|
- Cristian Salamea \<<cs@prisehub.com>\>
|
||||||
|
- Rod Schouteden \<<rod.schouteden@dynapps.be>\>
|
||||||
|
- Eugene Molotov \<<molotov@it-projects.info>\>
|
||||||
|
- Christopher Ormaza \<<chris.ormaza@forgeflow.com>\>
|
||||||
|
- Houz??fa Abbasbhay \<<houzefa.abba@xcg-consulting.fr>\>
|
|
@ -1,10 +0,0 @@
|
||||||
* Adrien Peiffer <adrien.peiffer@acsone.eu>
|
|
||||||
* S??bastien Alix <sebastien.alix@osiell.com>
|
|
||||||
* St??phane Bidoul <stephane.bidoul@acsone.eu>
|
|
||||||
* Enric Tobella <etobella@creublanca.es>
|
|
||||||
* Graeme Gellatly <gdgellatly@gmail.com>
|
|
||||||
* Cristian Salamea <cs@prisehub.com>
|
|
||||||
* Rod Schouteden <rod.schouteden@dynapps.be>
|
|
||||||
* Eugene Molotov <molotov@it-projects.info>
|
|
||||||
* Christopher Ormaza <chris.ormaza@forgeflow.com>
|
|
||||||
* Houz??fa Abbasbhay <houzefa.abba@xcg-consulting.fr>
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
Make sure you have `xlsxwriter` Python module installed:
|
||||||
|
|
||||||
|
$ pip3 install xlsxwriter
|
||||||
|
|
||||||
|
For testing it is also necessary `xlrd` Python module installed:
|
||||||
|
|
||||||
|
$ pip3 install xlrd
|
|
@ -1,7 +0,0 @@
|
||||||
Make sure you have ``xlsxwriter`` Python module installed::
|
|
||||||
|
|
||||||
$ pip3 install xlsxwriter
|
|
||||||
|
|
||||||
For testing it is also necessary ``xlrd`` Python module installed::
|
|
||||||
|
|
||||||
$ pip3 install xlrd
|
|
|
@ -1,6 +1,7 @@
|
||||||
An example of XLSX report for partners on a module called `module_name`:
|
An example of XLSX report for partners on a module called
|
||||||
|
\`module_name\`:
|
||||||
|
|
||||||
A python class ::
|
A python class :
|
||||||
|
|
||||||
from odoo import models
|
from odoo import models
|
||||||
|
|
||||||
|
@ -16,10 +17,10 @@ A python class ::
|
||||||
bold = workbook.add_format({'bold': True})
|
bold = workbook.add_format({'bold': True})
|
||||||
sheet.write(0, 0, obj.name, bold)
|
sheet.write(0, 0, obj.name, bold)
|
||||||
|
|
||||||
To manipulate the ``workbook`` and ``sheet`` objects, refer to the
|
To manipulate the `workbook` and `sheet` objects, refer to the
|
||||||
`documentation <http://xlsxwriter.readthedocs.org/>`_ of ``xlsxwriter``.
|
[documentation](http://xlsxwriter.readthedocs.org/) of `xlsxwriter`.
|
||||||
|
|
||||||
A report XML record ::
|
A report XML record :
|
||||||
|
|
||||||
<report
|
<report
|
||||||
id="partner_xlsx"
|
id="partner_xlsx"
|
|
@ -45,7 +45,7 @@ try:
|
||||||
re.search(pattern, sheetname) and int(sheetname[-2:]) or 0
|
re.search(pattern, sheetname) and int(sheetname[-2:]) or 0
|
||||||
)
|
)
|
||||||
# Only up to 100 duplicates
|
# Only up to 100 duplicates
|
||||||
deduplicated_secuence = "~{:02d}".format(duplicated_secuence + 1)
|
deduplicated_secuence = f"~{duplicated_secuence + 1:02d}"
|
||||||
if duplicated_secuence > 99:
|
if duplicated_secuence > 99:
|
||||||
raise xlsxwriter.exceptions.DuplicateWorksheetName # noqa: B904
|
raise xlsxwriter.exceptions.DuplicateWorksheetName # noqa: B904
|
||||||
if duplicated_secuence:
|
if duplicated_secuence:
|
||||||
|
|
|
@ -369,7 +369,7 @@ ul.auto-toc {
|
||||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
!! source digest: sha256:7b3079fe8522598fe2663c2ca653d380f864ca43319b7c0be50e6e83df8794a7
|
!! source digest: sha256:7b3079fe8522598fe2663c2ca653d380f864ca43319b7c0be50e6e83df8794a7
|
||||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||||
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Mature" src="https://img.shields.io/badge/maturity-Mature-brightgreen.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_xlsx"><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_xlsx"><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&target_branch=16.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="Mature" src="https://img.shields.io/badge/maturity-Mature-brightgreen.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/17.0/report_xlsx"><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-17-0/reporting-engine-17-0-report_xlsx"><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&target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
|
||||||
<p>This module provides a basic report class to generate xlsx report.</p>
|
<p>This module provides a basic report class to generate xlsx report.</p>
|
||||||
<p><strong>Table of contents</strong></p>
|
<p><strong>Table of contents</strong></p>
|
||||||
<div class="contents local topic" id="contents">
|
<div class="contents local topic" id="contents">
|
||||||
|
@ -398,8 +398,9 @@ $ pip3 install xlrd
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="usage">
|
<div class="section" id="usage">
|
||||||
<h1><a class="toc-backref" href="#toc-entry-2">Usage</a></h1>
|
<h1><a class="toc-backref" href="#toc-entry-2">Usage</a></h1>
|
||||||
<p>An example of XLSX report for partners on a module called <cite>module_name</cite>:</p>
|
<p>An example of XLSX report for partners on a module called
|
||||||
<p>A python class</p>
|
`module_name`:</p>
|
||||||
|
<p>A python class :</p>
|
||||||
<pre class="literal-block">
|
<pre class="literal-block">
|
||||||
from odoo import models
|
from odoo import models
|
||||||
|
|
||||||
|
@ -416,8 +417,9 @@ class PartnerXlsx(models.AbstractModel):
|
||||||
sheet.write(0, 0, obj.name, bold)
|
sheet.write(0, 0, obj.name, bold)
|
||||||
</pre>
|
</pre>
|
||||||
<p>To manipulate the <tt class="docutils literal">workbook</tt> and <tt class="docutils literal">sheet</tt> objects, refer to the
|
<p>To manipulate the <tt class="docutils literal">workbook</tt> and <tt class="docutils literal">sheet</tt> objects, refer to the
|
||||||
<a class="reference external" href="http://xlsxwriter.readthedocs.org/">documentation</a> of <tt class="docutils literal">xlsxwriter</tt>.</p>
|
<a class="reference external" href="http://xlsxwriter.readthedocs.org/">documentation</a> of
|
||||||
<p>A report XML record</p>
|
<tt class="docutils literal">xlsxwriter</tt>.</p>
|
||||||
|
<p>A report XML record :</p>
|
||||||
<pre class="literal-block">
|
<pre class="literal-block">
|
||||||
<report
|
<report
|
||||||
id="partner_xlsx"
|
id="partner_xlsx"
|
||||||
|
@ -435,7 +437,7 @@ class PartnerXlsx(models.AbstractModel):
|
||||||
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/reporting-engine/issues">GitHub Issues</a>.
|
<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.
|
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
|
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_xlsx%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
<a class="reference external" href="https://github.com/OCA/reporting-engine/issues/new?body=module:%20report_xlsx%0Aversion:%2017.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>
|
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="credits">
|
<div class="section" id="credits">
|
||||||
|
@ -469,7 +471,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
|
||||||
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
|
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||||
mission is to support the collaborative development of Odoo features and
|
mission is to support the collaborative development of Odoo features and
|
||||||
promote its widespread use.</p>
|
promote its widespread use.</p>
|
||||||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/reporting-engine/tree/16.0/report_xlsx">OCA/reporting-engine</a> project on GitHub.</p>
|
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/reporting-engine/tree/17.0/report_xlsx">OCA/reporting-engine</a> project on GitHub.</p>
|
||||||
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
|
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -42,7 +42,6 @@ class TestReport(common.TransactionCase):
|
||||||
self.assertEqual(attachment.name, f"{self.docs.name}.xlsx")
|
self.assertEqual(attachment.name, f"{self.docs.name}.xlsx")
|
||||||
|
|
||||||
def test_id_retrieval(self):
|
def test_id_retrieval(self):
|
||||||
|
|
||||||
# Typical call from WebUI with wizard
|
# Typical call from WebUI with wizard
|
||||||
objs = self.xlsx_report._get_objs_for_report(
|
objs = self.xlsx_report._get_objs_for_report(
|
||||||
False, {"context": {"active_ids": self.docs.ids}}
|
False, {"context": {"active_ids": self.docs.ids}}
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
# generated from manifests external_dependencies
|
||||||
|
xlrd
|
||||||
|
xlsxwriter
|
Loading…
Reference in New Issue