From 4776b1d416eca291a8a6a32b870ab6c0a2013c55 Mon Sep 17 00:00:00 2001 From: tien-ld Date: Wed, 22 Nov 2023 22:48:09 +0700 Subject: [PATCH] [IMP] report_xlsx: pre-commit auto fixes --- report_xlsx/README.rst | 102 ++++++++++-------- report_xlsx/controllers/main.py | 7 +- report_xlsx/pyproject.toml | 3 + report_xlsx/readme/CONTRIBUTORS.md | 10 ++ report_xlsx/readme/CONTRIBUTORS.rst | 10 -- .../{DESCRIPTION.rst => DESCRIPTION.md} | 0 report_xlsx/readme/INSTALL.md | 7 ++ report_xlsx/readme/INSTALL.rst | 7 -- report_xlsx/readme/{USAGE.rst => USAGE.md} | 11 +- report_xlsx/report/report_abstract_xlsx.py | 2 +- report_xlsx/static/description/index.html | 16 +-- report_xlsx/tests/test_report.py | 1 - 12 files changed, 97 insertions(+), 79 deletions(-) create mode 100644 report_xlsx/pyproject.toml create mode 100644 report_xlsx/readme/CONTRIBUTORS.md delete mode 100644 report_xlsx/readme/CONTRIBUTORS.rst rename report_xlsx/readme/{DESCRIPTION.rst => DESCRIPTION.md} (100%) create mode 100644 report_xlsx/readme/INSTALL.md delete mode 100644 report_xlsx/readme/INSTALL.rst rename report_xlsx/readme/{USAGE.rst => USAGE.md} (74%) diff --git a/report_xlsx/README.rst b/report_xlsx/README.rst index 5193ef785..14a5e7217 100644 --- a/report_xlsx/README.rst +++ b/report_xlsx/README.rst @@ -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 `_ of ``xlsxwriter``. +`documentation `__ of +``xlsxwriter``. -A report XML record :: +A report XML record : - +:: + + Bug Tracker =========== @@ -88,7 +98,7 @@ Bug Tracker Bugs are tracked on `GitHub 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 `_. +`feedback `_. 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 -* S??bastien Alix -* St??phane Bidoul -* Enric Tobella -* Graeme Gellatly -* Cristian Salamea -* Rod Schouteden -* Eugene Molotov -* Christopher Ormaza -* Houz??fa Abbasbhay +- Adrien Peiffer +- S??bastien Alix +- St??phane Bidoul +- Enric Tobella +- Graeme Gellatly +- Cristian Salamea +- Rod Schouteden +- Eugene Molotov +- Christopher Ormaza +- Houz??fa Abbasbhay 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 `_ project on GitHub. +This module is part of the `OCA/reporting-engine `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/report_xlsx/controllers/main.py b/report_xlsx/controllers/main.py index 2fce11df2..61aa5033b 100644 --- a/report_xlsx/controllers/main.py +++ b/report_xlsx/controllers/main.py @@ -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( diff --git a/report_xlsx/pyproject.toml b/report_xlsx/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/report_xlsx/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/report_xlsx/readme/CONTRIBUTORS.md b/report_xlsx/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..71197b4e2 --- /dev/null +++ b/report_xlsx/readme/CONTRIBUTORS.md @@ -0,0 +1,10 @@ +- Adrien Peiffer \<\> +- S??bastien Alix \<\> +- St??phane Bidoul \<\> +- Enric Tobella \<\> +- Graeme Gellatly \<\> +- Cristian Salamea \<\> +- Rod Schouteden \<\> +- Eugene Molotov \<\> +- Christopher Ormaza \<\> +- Houz??fa Abbasbhay \<\> diff --git a/report_xlsx/readme/CONTRIBUTORS.rst b/report_xlsx/readme/CONTRIBUTORS.rst deleted file mode 100644 index f9e7f1c59..000000000 --- a/report_xlsx/readme/CONTRIBUTORS.rst +++ /dev/null @@ -1,10 +0,0 @@ -* Adrien Peiffer -* S??bastien Alix -* St??phane Bidoul -* Enric Tobella -* Graeme Gellatly -* Cristian Salamea -* Rod Schouteden -* Eugene Molotov -* Christopher Ormaza -* Houz??fa Abbasbhay diff --git a/report_xlsx/readme/DESCRIPTION.rst b/report_xlsx/readme/DESCRIPTION.md similarity index 100% rename from report_xlsx/readme/DESCRIPTION.rst rename to report_xlsx/readme/DESCRIPTION.md diff --git a/report_xlsx/readme/INSTALL.md b/report_xlsx/readme/INSTALL.md new file mode 100644 index 000000000..013e31797 --- /dev/null +++ b/report_xlsx/readme/INSTALL.md @@ -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 diff --git a/report_xlsx/readme/INSTALL.rst b/report_xlsx/readme/INSTALL.rst deleted file mode 100644 index f75fbf25e..000000000 --- a/report_xlsx/readme/INSTALL.rst +++ /dev/null @@ -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 diff --git a/report_xlsx/readme/USAGE.rst b/report_xlsx/readme/USAGE.md similarity index 74% rename from report_xlsx/readme/USAGE.rst rename to report_xlsx/readme/USAGE.md index 751038564..e7dbcd3c3 100644 --- a/report_xlsx/readme/USAGE.rst +++ b/report_xlsx/readme/USAGE.md @@ -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 `_ 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 : 99: raise xlsxwriter.exceptions.DuplicateWorksheetName # noqa: B904 if duplicated_secuence: diff --git a/report_xlsx/static/description/index.html b/report_xlsx/static/description/index.html index 7949f5b7b..84cc89c5e 100644 --- a/report_xlsx/static/description/index.html +++ b/report_xlsx/static/description/index.html @@ -369,7 +369,7 @@ ul.auto-toc { !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! source digest: sha256:7b3079fe8522598fe2663c2ca653d380f864ca43319b7c0be50e6e83df8794a7 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Mature License: AGPL-3 OCA/reporting-engine Translate me on Weblate Try me on Runboat

+

Mature License: AGPL-3 OCA/reporting-engine Translate me on Weblate Try me on Runboat

This module provides a basic report class to generate xlsx report.

Table of contents

@@ -398,8 +398,9 @@ $ pip3 install xlrd

Usage

-

An example of XLSX report for partners on a module called module_name:

-

A python class

+

An example of XLSX report for partners on a module called +`module_name`:

+

A python class :

 from odoo import models
 
@@ -416,8 +417,9 @@ class PartnerXlsx(models.AbstractModel):
             sheet.write(0, 0, obj.name, bold)
 

To manipulate the workbook and sheet objects, refer to the -documentation of xlsxwriter.

-

A report XML record

+documentation of +xlsxwriter.

+

A report XML record :

 <report
     id="partner_xlsx"
@@ -435,7 +437,7 @@ class PartnerXlsx(models.AbstractModel):
 

Bugs are tracked on GitHub 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.

+feedback.

Do not contact contributors directly about support or help with technical issues.

@@ -469,7 +471,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome

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 project on GitHub.

+

This module is part of the OCA/reporting-engine project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

diff --git a/report_xlsx/tests/test_report.py b/report_xlsx/tests/test_report.py index 6bfb836b5..ef0457eae 100644 --- a/report_xlsx/tests/test_report.py +++ b/report_xlsx/tests/test_report.py @@ -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}}