[IMP] report_xlsx: pre-commit auto fixes

pull/819/head
tien-ld 2023-11-22 22:48:09 +07:00
parent dc48b19cff
commit 2381d65fb1
14 changed files with 599 additions and 578 deletions

Binary file not shown.

View File

@ -17,13 +17,13 @@ Base report xlsx
: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
: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
.. |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
.. |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
|badge1| |badge2| |badge3| |badge4| |badge5|
@ -38,49 +38,59 @@ This module provides a basic report class to generate xlsx report.
Installation
============
Make sure you have ``xlsxwriter`` Python module installed::
Make sure you have ``xlsxwriter`` Python module installed:
$ pip3 install xlsxwriter
::
For testing it is also necessary ``xlrd`` Python module installed::
$ pip3 install xlsxwriter
$ pip3 install xlrd
For testing it is also necessary ``xlrd`` Python module installed:
::
$ pip3 install xlrd
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
::
class PartnerXlsx(models.AbstractModel):
_name = 'report.module_name.report_name'
_inherit = 'report.report_xlsx.abstract'
from odoo import models
def generate_xlsx_report(self, workbook, data, partners):
for obj in partners:
report_name = obj.name
# One sheet by partner
sheet = workbook.add_worksheet(report_name[:31])
bold = workbook.add_format({'bold': True})
sheet.write(0, 0, obj.name, bold)
class PartnerXlsx(models.AbstractModel):
_name = 'report.module_name.report_name'
_inherit = 'report.report_xlsx.abstract'
def generate_xlsx_report(self, workbook, data, partners):
for obj in partners:
report_name = obj.name
# One sheet by partner
sheet = workbook.add_worksheet(report_name[:31])
bold = workbook.add_format({'bold': True})
sheet.write(0, 0, obj.name, bold)
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
id="partner_xlsx"
model="res.partner"
string="Print to XLSX"
report_type="xlsx"
name="module_name.report_name"
file="res_partner"
attachment_use="False"
/>
::
<report
id="partner_xlsx"
model="res.partner"
string="Print to XLSX"
report_type="xlsx"
name="module_name.report_name"
file="res_partner"
attachment_use="False"
/>
Bug Tracker
===========
@ -88,7 +98,7 @@ Bug Tracker
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.
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.
@ -96,27 +106,27 @@ Credits
=======
Authors
~~~~~~~
-------
* ACSONE SA/NV
* Creu Blanca
Contributors
~~~~~~~~~~~~
------------
* 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>
- 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>
Maintainers
~~~~~~~~~~~
-----------
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
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.

View File

@ -11,6 +11,8 @@ from odoo.http import (
content_disposition,
request,
route,
)
from odoo.http import (
serialize_exception as _serialize_exception,
)
from odoo.tools import html_escape
@ -69,8 +71,9 @@ class ReportController(ReportController):
url_decode(url.split("?")[1]).items()
) # decoding the args represented in JSON
if "context" in data:
context, data_context = json.loads(context or "{}"), json.loads(
data.pop("context")
context, data_context = (
json.loads(context or "{}"),
json.loads(data.pop("context")),
)
context = json.dumps({**context, **data_context})
response = self.report_routes(

View File

@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"

View File

@ -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>\>

View File

@ -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>

View File

@ -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

View File

@ -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

View File

@ -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
@ -16,10 +17,10 @@ A python class ::
bold = workbook.add_format({'bold': True})
sheet.write(0, 0, obj.name, bold)
To manipulate the ``workbook`` and ``sheet`` objects, refer to the
`documentation <http://xlsxwriter.readthedocs.org/>`_ of ``xlsxwriter``.
To manipulate the `workbook` and `sheet` objects, refer to the
[documentation](http://xlsxwriter.readthedocs.org/) of `xlsxwriter`.
A report XML record ::
A report XML record :
<report
id="partner_xlsx"

View File

@ -45,7 +45,7 @@ try:
re.search(pattern, sheetname) and int(sheetname[-2:]) or 0
)
# Only up to 100 duplicates
deduplicated_secuence = "~{:02d}".format(duplicated_secuence + 1)
deduplicated_secuence = f"~{duplicated_secuence + 1:02d}"
if duplicated_secuence > 99:
raise xlsxwriter.exceptions.DuplicateWorksheetName # noqa: B904
if duplicated_secuence:

View File

@ -369,7 +369,7 @@ ul.auto-toc {
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! 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&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><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&amp;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><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
@ -398,8 +398,9 @@ $ pip3 install xlrd
</div>
<div class="section" id="usage">
<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>A python class</p>
<p>An example of XLSX report for partners on a module called
`module_name`:</p>
<p>A python class :</p>
<pre class="literal-block">
from odoo import models
@ -416,8 +417,9 @@ class PartnerXlsx(models.AbstractModel):
sheet.write(0, 0, obj.name, bold)
</pre>
<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>
<p>A report XML record</p>
<a class="reference external" href="http://xlsxwriter.readthedocs.org/">documentation</a> of
<tt class="docutils literal">xlsxwriter</tt>.</p>
<p>A report XML record :</p>
<pre class="literal-block">
&lt;report
id=&quot;partner_xlsx&quot;
@ -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>.
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_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>
</div>
<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
mission is to support the collaborative development of Odoo features and
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>
</div>
</div>

View File

@ -42,7 +42,6 @@ class TestReport(common.TransactionCase):
self.assertEqual(attachment.name, f"{self.docs.name}.xlsx")
def test_id_retrieval(self):
# Typical call from WebUI with wizard
objs = self.xlsx_report._get_objs_for_report(
False, {"context": {"active_ids": self.docs.ids}}

3
requirements.txt 100644
View File

@ -0,0 +1,3 @@
# generated from manifests external_dependencies
xlrd
xlsxwriter