update: report_xlsx to OCA 19.0 version (19.0.1.0.2)

🤖 assisted by claude
This commit is contained in:
Ernad Husremovic 2026-03-09 22:16:29 +01:00
parent 8566ac3819
commit 32a4fa90f7
23 changed files with 201 additions and 206 deletions

View file

@ -1,3 +1,7 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association
================ ================
Base report xlsx Base report xlsx
================ ================
@ -7,23 +11,23 @@ Base report xlsx
!! This file is generated by oca-gen-addon-readme !! !! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !! !! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:1b8ed9ba68eb80158d4a236896a641b3ef8f79c2068525b03d67d67e72d20dcd !! source digest: sha256:61af5f70a44c329b90fa1b3c7e98e743299c3bb6c1d8c385563d620f18d835e9
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Mature-brightgreen.png .. |badge1| image:: https://img.shields.io/badge/maturity-Mature-brightgreen.png
:target: https://odoo-community.org/page/development-status :target: https://odoo-community.org/page/development-status
:alt: Mature :alt: Mature
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png .. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
: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/19.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-19-0/reporting-engine-19-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=19.0
:alt: Try me on Runboat :alt: Try me on Runboat
|badge1| |badge2| |badge3| |badge4| |badge5| |badge1| |badge2| |badge3| |badge4| |badge5|
@ -38,50 +42,60 @@ 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 ::
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 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): from odoo import models
_name = 'report.module_name.report_name'
_inherit = 'report.report_xlsx.abstract'
def generate_xlsx_report(self, workbook, data, partners): class PartnerXlsx(models.AbstractModel):
for obj in partners: _name = 'report.module_name.report_name'
report_name = obj.name _inherit = 'report.report_xlsx.abstract'
# One sheet by partner
sheet = workbook.add_worksheet(report_name[:31]) def generate_xlsx_report(self, workbook, data, partners):
bold = workbook.add_format({'bold': True}) for obj in partners:
sheet.write(0, 0, obj.name, bold) 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 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 :
<record id="action_report_partner_xlsx" model="ir.actions.report"> ::
<field name="name">Print to XLSX</field>
<field name="model">res.partner</field> <record id="action_report_partner_xlsx" model="ir.actions.report">
<field name="report_type">xlsx</field> <field name="name">Print to XLSX</field>
<field name="report_name">module_name.report_name</field> <field name="model">res.partner</field>
<field name="report_file">module_name.report_file</field> <field name="report_type">xlsx</field>
<field name="binding_model_id" ref="res.partner"/> <field name="report_name">module_name.report_name</field>
<field name="binding_type">report</field> <field name="report_file">module_name.report_file</field>
<field name="attachment_use" eval="False"/> <field name="binding_model_id" ref="res.partner"/>
</record> <field name="binding_type">report</field>
<field name="attachment_use" eval="False"/>
</record>
Bug Tracker Bug Tracker
=========== ===========
@ -89,7 +103,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:%2019.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.
@ -97,27 +111,28 @@ 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>
- Le Dinh Tien <tien-ld@komit-consulting.com>
Maintainers Maintainers
~~~~~~~~~~~ -----------
This module is maintained by the OCA. This module is maintained by the OCA.
@ -129,6 +144,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/19.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.

View file

@ -3,12 +3,13 @@
{ {
"name": "Base report xlsx", "name": "Base report xlsx",
"summary": "Base module to create xlsx report", "summary": "Base module to create xlsx report",
"author": "ACSONE SA/NV," "Creu Blanca," "Odoo Community Association (OCA)", "author": "ACSONE SA/NV,Creu Blanca,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/reporting-engine", "website": "https://github.com/OCA/reporting-engine",
"category": "Reporting", "category": "Reporting",
"version": "16.0.2.0.2", "version": "19.0.1.0.2",
"development_status": "Mature", "development_status": "Mature",
"license": "AGPL-3", "license": "AGPL-3",
"external_dependencies": {"python": ["xlsxwriter", "xlrd"]},
"depends": ["base", "web"], "depends": ["base", "web"],
"demo": ["demo/report.xml"], "demo": ["demo/report.xml"],
"installable": True, "installable": True,

View file

@ -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
@ -40,8 +42,7 @@ class ReportController(ReportController):
xlsxhttpheaders = [ xlsxhttpheaders = [
( (
"Content-Type", "Content-Type",
"application/vnd.openxmlformats-" "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"officedocument.spreadsheetml.sheet",
), ),
("Content-Length", len(xlsx)), ("Content-Length", len(xlsx)),
] ]
@ -49,7 +50,7 @@ class ReportController(ReportController):
return super().report_routes(reportname, docids, converter, **data) return super().report_routes(reportname, docids, converter, **data)
@route() @route()
def report_download(self, data, context=None, token=None): def report_download(self, data, context=None, token=None, readonly=True):
requestcontent = json.loads(data) requestcontent = json.loads(data)
url, report_type = requestcontent[0], requestcontent[1] url, report_type = requestcontent[0], requestcontent[1]
if report_type == "xlsx": if report_type == "xlsx":
@ -69,8 +70,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(
@ -80,7 +82,7 @@ class ReportController(ReportController):
report = request.env["ir.actions.report"]._get_report_from_name( report = request.env["ir.actions.report"]._get_report_from_name(
reportname reportname
) )
filename = "%s.%s" % (report.name, "xlsx") filename = f"{report.name}.xlsx"
if docids: if docids:
ids = [int(x) for x in docids.split(",")] ids = [int(x) for x in docids.split(",")]
@ -89,7 +91,7 @@ class ReportController(ReportController):
report_name = safe_eval( report_name = safe_eval(
report.print_report_name, {"object": obj, "time": time} report.print_report_name, {"object": obj, "time": time}
) )
filename = "%s.%s" % (report_name, "xlsx") filename = f"{report_name}.xlsx"
if not response.headers.get("Content-Disposition"): if not response.headers.get("Content-Disposition"):
response.headers.add( response.headers.add(
"Content-Disposition", content_disposition(filename) "Content-Disposition", content_disposition(filename)
@ -101,4 +103,6 @@ class ReportController(ReportController):
error = {"code": 200, "message": "Odoo Server Error", "data": se} error = {"code": 200, "message": "Odoo Server Error", "data": se}
return request.make_response(html_escape(json.dumps(error))) return request.make_response(html_escape(json.dumps(error)))
else: else:
return super().report_download(data, context=context, token=token) return super().report_download(
data, context, token=token, readonly=readonly
)

View file

@ -1,53 +0,0 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * report_xlsx
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: report_xlsx
#: model:ir.model,name:report_xlsx.model_report_report_xlsx_abstract
msgid "Abstract XLSX Report"
msgstr "Apstraktni XLSX izvještaj"
#. module: report_xlsx
#: model:ir.model,name:report_xlsx.model_report_report_xlsx_partner_xlsx
msgid "Partner XLSX Report"
msgstr "XLSX izvještaj o partnerima"
#. module: report_xlsx
#: model:ir.actions.report,name:report_xlsx.partner_xlsx
msgid "Print to XLSX"
msgstr "Štampaj u XLSX"
#. module: report_xlsx
#: model:ir.model,name:report_xlsx.model_ir_actions_report
msgid "Report Action"
msgstr "Akcija izvještaja"
#. module: report_xlsx
#: model:ir.model.fields,field_description:report_xlsx.field_ir_actions_report__report_type
msgid "Report Type"
msgstr "Tip izvještaja"
#. module: report_xlsx
#: model:ir.model.fields,help:report_xlsx.field_ir_actions_report__report_type
msgid ""
"The type of the report that will be rendered, each one having its own "
"rendering method. HTML means the report will be opened directly in your "
"browser PDF means the report will be rendered using Wkhtmltopdf and "
"downloaded by the user."
msgstr ""
#. module: report_xlsx
#: model:ir.model.fields.selection,name:report_xlsx.selection__ir_actions_report__report_type__xlsx
msgid "XLSX"
msgstr "XLSX"

View file

@ -9,25 +9,24 @@ msgstr ""
"Project-Id-Version: Odoo Server 11.0\n" "Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-01-05 17:53+0000\n" "POT-Creation-Date: 2018-01-05 17:53+0000\n"
"PO-Revision-Date: 2024-12-31 15:06+0000\n" "PO-Revision-Date: 2018-01-05 17:53+0000\n"
"Last-Translator: samibc2c <sami.bouzidi@camptocamp.com>\n" "Last-Translator: Nicolas JEUDY <njeudy@panda-chi.io>, 2018\n"
"Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n" "Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n"
"Language: fr\n" "Language: fr\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n" "Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n > 1;\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n"
"X-Generator: Weblate 5.6.2\n"
#. module: report_xlsx #. module: report_xlsx
#: model:ir.model,name:report_xlsx.model_report_report_xlsx_abstract #: model:ir.model,name:report_xlsx.model_report_report_xlsx_abstract
msgid "Abstract XLSX Report" msgid "Abstract XLSX Report"
msgstr "Rapport résumé XLSX" msgstr ""
#. module: report_xlsx #. module: report_xlsx
#: model:ir.model,name:report_xlsx.model_report_report_xlsx_partner_xlsx #: model:ir.model,name:report_xlsx.model_report_report_xlsx_partner_xlsx
msgid "Partner XLSX Report" msgid "Partner XLSX Report"
msgstr "Rapport XLSX du partenaire" msgstr ""
#. module: report_xlsx #. module: report_xlsx
#: model:ir.actions.report,name:report_xlsx.partner_xlsx #: model:ir.actions.report,name:report_xlsx.partner_xlsx
@ -37,12 +36,12 @@ msgstr "Imprimer en XLSX"
#. module: report_xlsx #. module: report_xlsx
#: model:ir.model,name:report_xlsx.model_ir_actions_report #: model:ir.model,name:report_xlsx.model_ir_actions_report
msgid "Report Action" msgid "Report Action"
msgstr "Action rapport" msgstr ""
#. module: report_xlsx #. module: report_xlsx
#: model:ir.model.fields,field_description:report_xlsx.field_ir_actions_report__report_type #: model:ir.model.fields,field_description:report_xlsx.field_ir_actions_report__report_type
msgid "Report Type" msgid "Report Type"
msgstr "Type de rapport" msgstr ""
#. module: report_xlsx #. module: report_xlsx
#: model:ir.model.fields,help:report_xlsx.field_ir_actions_report__report_type #: model:ir.model.fields,help:report_xlsx.field_ir_actions_report__report_type
@ -52,15 +51,11 @@ msgid ""
"browser PDF means the report will be rendered using Wkhtmltopdf and " "browser PDF means the report will be rendered using Wkhtmltopdf and "
"downloaded by the user." "downloaded by the user."
msgstr "" msgstr ""
"Type de rapport qui sera généré, chacun ayant sa propre méthode de "
"génération de rapports. HTML signifie que le rapport sera ouvert directement "
"dans votre navigateur PDF signifie que le rapport sera généré à l'aide de "
"Wkhtmltopdf et téléchargé par l'utilisateur."
#. module: report_xlsx #. module: report_xlsx
#: model:ir.model.fields.selection,name:report_xlsx.selection__ir_actions_report__report_type__xlsx #: model:ir.model.fields.selection,name:report_xlsx.selection__ir_actions_report__report_type__xlsx
msgid "XLSX" msgid "XLSX"
msgstr "XLSX" msgstr ""
#, python-format #, python-format
#~ msgid "%s model was not found" #~ msgid "%s model was not found"

View file

@ -16,8 +16,8 @@ msgstr ""
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n" "Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" "Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && "
"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" "n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"
"X-Generator: Weblate 4.14.1\n" "X-Generator: Weblate 4.14.1\n"
#. module: report_xlsx #. module: report_xlsx

View file

@ -17,8 +17,8 @@ msgstr ""
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n" "Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" "Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && "
"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" "n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"
#. module: report_xlsx #. module: report_xlsx
#: model:ir.model,name:report_xlsx.model_report_report_xlsx_abstract #: model:ir.model,name:report_xlsx.model_report_report_xlsx_abstract

View file

@ -9,7 +9,7 @@ msgstr ""
"Project-Id-Version: Odoo Server 10.0\n" "Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-05-31 03:52+0000\n" "POT-Creation-Date: 2017-05-31 03:52+0000\n"
"PO-Revision-Date: 2024-01-18 09:34+0000\n" "PO-Revision-Date: 2024-02-12 10:46+0000\n"
"Last-Translator: mymage <stefano.consolaro@mymage.it>\n" "Last-Translator: mymage <stefano.consolaro@mymage.it>\n"
"Language-Team: Italian (https://www.transifex.com/oca/teams/23907/it/)\n" "Language-Team: Italian (https://www.transifex.com/oca/teams/23907/it/)\n"
"Language: it\n" "Language: it\n"

View file

@ -4,7 +4,7 @@
# #
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Odoo Server 16.0\n" "Project-Id-Version: Odoo Server 19.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"Last-Translator: \n" "Last-Translator: \n"
"Language-Team: \n" "Language-Team: \n"
@ -19,13 +19,22 @@ msgid "Abstract XLSX Report"
msgstr "" msgstr ""
#. module: report_xlsx #. module: report_xlsx
#: model:ir.model,name:report_xlsx.model_report_report_xlsx_partner_xlsx #: model:ir.model.fields,field_description:report_xlsx.field_ir_actions_report__display_name
msgid "Partner XLSX Report" #: model:ir.model.fields,field_description:report_xlsx.field_report_report_xlsx_abstract__display_name
#: model:ir.model.fields,field_description:report_xlsx.field_report_report_xlsx_partner_xlsx__display_name
msgid "Display Name"
msgstr "" msgstr ""
#. module: report_xlsx #. module: report_xlsx
#: model:ir.actions.report,name:report_xlsx.partner_xlsx #: model:ir.model.fields,field_description:report_xlsx.field_ir_actions_report__id
msgid "Print to XLSX" #: model:ir.model.fields,field_description:report_xlsx.field_report_report_xlsx_abstract__id
#: model:ir.model.fields,field_description:report_xlsx.field_report_report_xlsx_partner_xlsx__id
msgid "ID"
msgstr ""
#. module: report_xlsx
#: model:ir.model,name:report_xlsx.model_report_report_xlsx_partner_xlsx
msgid "Partner XLSX Report"
msgstr "" msgstr ""
#. module: report_xlsx #. module: report_xlsx

View file

@ -6,20 +6,20 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Odoo Server 14.0\n" "Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2021-11-30 10:36+0000\n" "PO-Revision-Date: 2024-06-12 08:55+0000\n"
"Last-Translator: Simon S <simon.stromberg@vertel.se>\n" "Last-Translator: jakobkrabbe <jakob@syscare.se>\n"
"Language-Team: none\n" "Language-Team: none\n"
"Language: sv\n" "Language: sv\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n" "Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n" "Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.3.2\n" "X-Generator: Weblate 4.17\n"
#. module: report_xlsx #. module: report_xlsx
#: model:ir.model,name:report_xlsx.model_report_report_xlsx_abstract #: model:ir.model,name:report_xlsx.model_report_report_xlsx_abstract
msgid "Abstract XLSX Report" msgid "Abstract XLSX Report"
msgstr "" msgstr "Abstrakt XLSX-rapport"
#. module: report_xlsx #. module: report_xlsx
#: model:ir.model,name:report_xlsx.model_report_report_xlsx_partner_xlsx #: model:ir.model,name:report_xlsx.model_report_report_xlsx_partner_xlsx

View file

@ -9,39 +9,40 @@ msgstr ""
"Project-Id-Version: Odoo Server 10.0\n" "Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-05-31 03:52+0000\n" "POT-Creation-Date: 2017-05-31 03:52+0000\n"
"PO-Revision-Date: 2017-05-31 03:52+0000\n" "PO-Revision-Date: 2025-09-10 11:42+0000\n"
"Last-Translator: OCA Transbot <transbot@odoo-community.org>, 2017\n" "Last-Translator: Tamer Sezgin <tamer.sezgin@gmail.com>\n"
"Language-Team: Turkish (https://www.transifex.com/oca/teams/23907/tr/)\n" "Language-Team: Turkish (https://www.transifex.com/oca/teams/23907/tr/)\n"
"Language: tr\n" "Language: tr\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n" "Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n"
"X-Generator: Weblate 5.10.4\n"
#. module: report_xlsx #. module: report_xlsx
#: model:ir.model,name:report_xlsx.model_report_report_xlsx_abstract #: model:ir.model,name:report_xlsx.model_report_report_xlsx_abstract
msgid "Abstract XLSX Report" msgid "Abstract XLSX Report"
msgstr "" msgstr "Temel XLSX Çıktısı"
#. module: report_xlsx #. module: report_xlsx
#: model:ir.model,name:report_xlsx.model_report_report_xlsx_partner_xlsx #: model:ir.model,name:report_xlsx.model_report_report_xlsx_partner_xlsx
msgid "Partner XLSX Report" msgid "Partner XLSX Report"
msgstr "" msgstr "İş Ortağı XLSX Raporu"
#. module: report_xlsx #. module: report_xlsx
#: model:ir.actions.report,name:report_xlsx.partner_xlsx #: model:ir.actions.report,name:report_xlsx.partner_xlsx
msgid "Print to XLSX" msgid "Print to XLSX"
msgstr "" msgstr "XLSX Yazdır"
#. module: report_xlsx #. module: report_xlsx
#: model:ir.model,name:report_xlsx.model_ir_actions_report #: model:ir.model,name:report_xlsx.model_ir_actions_report
msgid "Report Action" msgid "Report Action"
msgstr "" msgstr "Rapor Eylemi"
#. module: report_xlsx #. module: report_xlsx
#: model:ir.model.fields,field_description:report_xlsx.field_ir_actions_report__report_type #: model:ir.model.fields,field_description:report_xlsx.field_ir_actions_report__report_type
msgid "Report Type" msgid "Report Type"
msgstr "" msgstr "Çıktı Türü"
#. module: report_xlsx #. module: report_xlsx
#: model:ir.model.fields,help:report_xlsx.field_ir_actions_report__report_type #: model:ir.model.fields,help:report_xlsx.field_ir_actions_report__report_type
@ -51,11 +52,15 @@ msgid ""
"browser PDF means the report will be rendered using Wkhtmltopdf and " "browser PDF means the report will be rendered using Wkhtmltopdf and "
"downloaded by the user." "downloaded by the user."
msgstr "" msgstr ""
"Her biri kendi oluşturma yöntemine sahip olarak oluşturulacak raporun türü. "
"HTML, raporun doğrudan tarayıcınızda açılacağı anlamına gelir PDF, raporun "
"Wkhtmltopdf kullanılarak oluşturulacağı ve kullanıcı tarafından indirileceği "
"anlamına gelir."
#. module: report_xlsx #. module: report_xlsx
#: model:ir.model.fields.selection,name:report_xlsx.selection__ir_actions_report__report_type__xlsx #: model:ir.model.fields.selection,name:report_xlsx.selection__ir_actions_report__report_type__xlsx
msgid "XLSX" msgid "XLSX"
msgstr "" msgstr "XLSX"
#, fuzzy #, fuzzy
#~ msgid "ir.actions.report" #~ msgid "ir.actions.report"

View file

@ -19,14 +19,14 @@ class ReportAction(models.Model):
@api.model @api.model
def _render_xlsx(self, report_ref, docids, data): def _render_xlsx(self, report_ref, docids, data):
report_sudo = self._get_report(report_ref) report_sudo = self._get_report(report_ref)
report_model_name = "report.%s" % report_sudo.report_name report_model_name = f"report.{report_sudo.report_name}"
report_model = self.env[report_model_name] report_model = self.env[report_model_name]
ret = ( ret = (
report_model.with_context(active_model=report_sudo.model) report_model.with_context(active_model=report_sudo.model)
.sudo(False) .sudo(False)
.create_xlsx_report(docids, data) # noqa .create_xlsx_report(docids, data) # noqa
) )
if ret and isinstance(ret, (tuple, list)): # data, "xlsx" if ret and isinstance(ret, (tuple | list)): # data, "xlsx"
report_sudo.save_xlsx_report_attachment(docids, ret[0]) report_sudo.save_xlsx_report_attachment(docids, ret[0])
return ret return ret

View file

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

View file

@ -0,0 +1,11 @@
- 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>\>
- Le Dinh Tien \<<tien-ld@komit-consulting.com>\>

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 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 :
<record id="action_report_partner_xlsx" model="ir.actions.report"> <record id="action_report_partner_xlsx" model="ir.actions.report">
<field name="name">Print to XLSX</field> <field name="name">Print to XLSX</field>

View file

@ -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:
@ -95,7 +95,7 @@ class ReportXlsxAbstract(models.AbstractModel):
"""Get the format to be used in cells (symbol included). """Get the format to be used in cells (symbol included).
Used in account_financial_report addon""" Used in account_financial_report addon"""
s_before = currency.symbol if currency.position == "before" else "" s_before = currency.symbol if currency.position == "before" else ""
s_after = " %s" % currency.symbol if currency.position == "after" else "" s_after = f" {currency.symbol}" if currency.position == "after" else ""
return f"{f'{s_before}'}#,##0.{'0' * currency.decimal_places}{f'{s_after}'}" return f"{f'{s_before}'}#,##0.{'0' * currency.decimal_places}{f'{s_after}'}"
def create_xlsx_report(self, docids, data): def create_xlsx_report(self, docids, data):

View file

@ -3,7 +3,7 @@
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" /> <meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>Base report xlsx</title> <title>README.rst</title>
<style type="text/css"> <style type="text/css">
/* /*
@ -360,16 +360,21 @@ ul.auto-toc {
</style> </style>
</head> </head>
<body> <body>
<div class="document" id="base-report-xlsx"> <div class="document">
<h1 class="title">Base report xlsx</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="base-report-xlsx">
<h1>Base report xlsx</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! <!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !! !! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !! !! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:1b8ed9ba68eb80158d4a236896a641b3ef8f79c2068525b03d67d67e72d20dcd !! source digest: sha256:61af5f70a44c329b90fa1b3c7e98e743299c3bb6c1d8c385563d620f18d835e9
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/reporting-engine/tree/19.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-19-0/reporting-engine-19-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=19.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">
@ -386,7 +391,7 @@ ul.auto-toc {
</ul> </ul>
</div> </div>
<div class="section" id="installation"> <div class="section" id="installation">
<h1><a class="toc-backref" href="#toc-entry-1">Installation</a></h1> <h2><a class="toc-backref" href="#toc-entry-1">Installation</a></h2>
<p>Make sure you have <tt class="docutils literal">xlsxwriter</tt> Python module installed:</p> <p>Make sure you have <tt class="docutils literal">xlsxwriter</tt> Python module installed:</p>
<pre class="literal-block"> <pre class="literal-block">
$ pip3 install xlsxwriter $ pip3 install xlsxwriter
@ -397,9 +402,10 @@ $ pip3 install xlrd
</pre> </pre>
</div> </div>
<div class="section" id="usage"> <div class="section" id="usage">
<h1><a class="toc-backref" href="#toc-entry-2">Usage</a></h1> <h2><a class="toc-backref" href="#toc-entry-2">Usage</a></h2>
<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 +422,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">
&lt;record id=&quot;action_report_partner_xlsx&quot; model=&quot;ir.actions.report&quot;&gt; &lt;record id=&quot;action_report_partner_xlsx&quot; model=&quot;ir.actions.report&quot;&gt;
&lt;field name=&quot;name&quot;&gt;Print to XLSX&lt;/field&gt; &lt;field name=&quot;name&quot;&gt;Print to XLSX&lt;/field&gt;
@ -432,24 +439,24 @@ class PartnerXlsx(models.AbstractModel):
</pre> </pre>
</div> </div>
<div class="section" id="bug-tracker"> <div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h1> <h2><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h2>
<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:%2019.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">
<h1><a class="toc-backref" href="#toc-entry-4">Credits</a></h1> <h2><a class="toc-backref" href="#toc-entry-4">Credits</a></h2>
<div class="section" id="authors"> <div class="section" id="authors">
<h2><a class="toc-backref" href="#toc-entry-5">Authors</a></h2> <h3><a class="toc-backref" href="#toc-entry-5">Authors</a></h3>
<ul class="simple"> <ul class="simple">
<li>ACSONE SA/NV</li> <li>ACSONE SA/NV</li>
<li>Creu Blanca</li> <li>Creu Blanca</li>
</ul> </ul>
</div> </div>
<div class="section" id="contributors"> <div class="section" id="contributors">
<h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2> <h3><a class="toc-backref" href="#toc-entry-6">Contributors</a></h3>
<ul class="simple"> <ul class="simple">
<li>Adrien Peiffer &lt;<a class="reference external" href="mailto:adrien.peiffer&#64;acsone.eu">adrien.peiffer&#64;acsone.eu</a>&gt;</li> <li>Adrien Peiffer &lt;<a class="reference external" href="mailto:adrien.peiffer&#64;acsone.eu">adrien.peiffer&#64;acsone.eu</a>&gt;</li>
<li>Sébastien Alix &lt;<a class="reference external" href="mailto:sebastien.alix&#64;osiell.com">sebastien.alix&#64;osiell.com</a>&gt;</li> <li>Sébastien Alix &lt;<a class="reference external" href="mailto:sebastien.alix&#64;osiell.com">sebastien.alix&#64;osiell.com</a>&gt;</li>
@ -461,10 +468,11 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
<li>Eugene Molotov &lt;<a class="reference external" href="mailto:molotov&#64;it-projects.info">molotov&#64;it-projects.info</a>&gt;</li> <li>Eugene Molotov &lt;<a class="reference external" href="mailto:molotov&#64;it-projects.info">molotov&#64;it-projects.info</a>&gt;</li>
<li>Christopher Ormaza &lt;<a class="reference external" href="mailto:chris.ormaza&#64;forgeflow.com">chris.ormaza&#64;forgeflow.com</a>&gt;</li> <li>Christopher Ormaza &lt;<a class="reference external" href="mailto:chris.ormaza&#64;forgeflow.com">chris.ormaza&#64;forgeflow.com</a>&gt;</li>
<li>Houzéfa Abbasbhay &lt;<a class="reference external" href="mailto:houzefa.abba&#64;xcg-consulting.fr">houzefa.abba&#64;xcg-consulting.fr</a>&gt;</li> <li>Houzéfa Abbasbhay &lt;<a class="reference external" href="mailto:houzefa.abba&#64;xcg-consulting.fr">houzefa.abba&#64;xcg-consulting.fr</a>&gt;</li>
<li>Le Dinh Tien &lt;<a class="reference external" href="mailto:tien-ld&#64;komit-consulting.com">tien-ld&#64;komit-consulting.com</a>&gt;</li>
</ul> </ul>
</div> </div>
<div class="section" id="maintainers"> <div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2> <h3><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h3>
<p>This module is maintained by the OCA.</p> <p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"> <a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /> <img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
@ -472,10 +480,11 @@ 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/19.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>
</div> </div>
</div>
</body> </body>
</html> </html>

View file

@ -1,7 +1,6 @@
/** @odoo-module **/
import {download} from "@web/core/network/download"; import {download} from "@web/core/network/download";
import {registry} from "@web/core/registry"; import {registry} from "@web/core/registry";
import {user} from "@web/core/user";
registry registry
.category("ir.actions.report handlers") .category("ir.actions.report handlers")
@ -21,9 +20,7 @@ registry
url += `/${actionContext.active_ids.join(",")}`; url += `/${actionContext.active_ids.join(",")}`;
} }
if (type === "xlsx") { if (type === "xlsx") {
const context = encodeURIComponent( const context = encodeURIComponent(JSON.stringify(user.context));
JSON.stringify(env.services.user.context)
);
url += `?context=${context}`; url += `?context=${context}`;
} }
} }
@ -33,7 +30,7 @@ registry
url: "/report/download", url: "/report/download",
data: { data: {
data: JSON.stringify([url, action.report_type]), data: JSON.stringify([url, action.report_type]),
context: JSON.stringify(env.services.user.context), context: JSON.stringify(user.context),
}, },
}); });
} finally { } finally {

View file

@ -1,6 +1,7 @@
# Copyright 2017 Creu Blanca # Copyright 2017 Creu Blanca
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
import io
import logging import logging
from odoo.tests import common from odoo.tests import common
@ -8,33 +9,41 @@ from odoo.tests import common
_logger = logging.getLogger(__name__) _logger = logging.getLogger(__name__)
try: try:
from xlrd import open_workbook from openpyxl import load_workbook
except ImportError: except ImportError:
_logger.debug("Can not import xlrd`.") _logger.debug("Can not import openpyxl`.")
class TestReport(common.TransactionCase): class TestReport(common.TransactionCase):
def setUp(self): def setUp(self):
super().setUp() super().setUp()
self.report_object = self.env["ir.actions.report"] self.report_object = self.env["ir.actions.report"]
vals = {
"name": "Print to XLSX",
"model": "res.partner",
"report_type": "xlsx",
"report_name": "report_xlsx.partner_xlsx",
"report_file": "res_partner",
}
self.xlsx_report = self.env["report.report_xlsx.abstract"].with_context( self.xlsx_report = self.env["report.report_xlsx.abstract"].with_context(
active_model="res.partner" active_model="res.partner"
) )
self.report_name = "report_xlsx.partner_xlsx" self.report_name = "report_xlsx.partner_xlsx"
self.report = self.report_object._get_report_from_name(self.report_name) self.report = self.report_object.create(vals)
self.docs = self.env["res.company"].search([], limit=1).partner_id self.docs = self.env["res.company"].search([], limit=1).partner_id
def test_report(self): def test_report(self):
report = self.report report = self.report
self.assertEqual(report.report_type, "xlsx") self.assertEqual(report.report_type, "xlsx")
rep = self.report_object._render(self.report_name, self.docs.ids, {}) rep = self.report_object._render(self.report, self.docs.ids, {})
wb = open_workbook(file_contents=rep[0]) file = io.BytesIO(rep[0])
sheet = wb.sheet_by_index(0) wb = load_workbook(file)
self.assertEqual(sheet.cell(0, 0).value, self.docs.name) sheet = wb.active
self.assertEqual(sheet.cell(1, 1).value, self.docs.name)
def test_save_attachment(self): def test_save_attachment(self):
self.report.attachment = 'object.name + ".xlsx"' self.report.attachment = 'object.name + ".xlsx"'
self.report_object._render(self.report_name, self.docs.ids, {}) self.report_object._render(self.report, self.docs.ids, {})
attachment = self.env["ir.attachment"].search( attachment = self.env["ir.attachment"].search(
[("res_id", "=", self.docs.id), ("res_model", "=", self.docs._name)] [("res_id", "=", self.docs.id), ("res_model", "=", self.docs._name)]
) )
@ -42,7 +51,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}}