Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
190 commits
Select commit Hold shift + click to select a range
6b4cee9
[CHG] Rename base_report_xlsx to report_xlsx and add xlsx report type…
Apr 4, 2016
fc73124
[IMP] report_xlsx - Pass the report instance as well as ids of record…
sebalix Apr 12, 2016
1a68ac0
[MIG] Migration of report_xlsx to 10.0 (#76)
Oct 13, 2016
b858c6c
[10.0] report_xlsx: Allow to define options for workbook creation (#98)
sbidoul Feb 22, 2017
6cdead6
OCA Transbot updated translations from Transifex
oca-transbot Nov 29, 2016
5069860
[MIG] report_xlsx: Migration to 11.0
etobella Oct 25, 2017
a75febf
OCA Transbot updated translations from Transifex
oca-transbot Dec 30, 2017
e29a91a
[IMP] report_fillpdf, report_xlsx, report_xml: Use content_dispositio…
naglis Mar 11, 2018
0c49640
[UPD] Update report_xlsx.pot
oca-travis Jul 24, 2018
156281e
Fix report_xlsx for printing from wizards
gdgellatly Aug 25, 2018
c96a122
[MIG] report_xlsx: Migration to 12.0
ovnicraft Oct 8, 2018
936fe1b
[IMP] report_xlsx: README by fragments
pedrobaeza Dec 21, 2018
4552c32
[UPD] Update report_xlsx.pot
oca-travis Dec 21, 2018
42cc6ed
Update translation files
oca-transbot Dec 29, 2018
9f81e7a
Translated using Weblate (German)
rschnapka Apr 24, 2019
a2a44f5
[UPD] README.rst
OCA-git-bot Jul 31, 2019
1a56b7b
[12.0][IMP] report_xlsx, make sure print_report_name works
kittiu Aug 9, 2019
663080b
Added translation using Weblate (Portuguese)
pedrocs-exo Aug 14, 2019
41cda3d
Translated using Weblate (Portuguese)
pedrocs-exo Aug 14, 2019
22bb5b5
report_xlsx 12.0.1.0.1
OCA-git-bot Sep 23, 2019
e85fac2
[MIG] report_xlsx: Migration to 13.0
schout-it Oct 1, 2019
85cce19
[MIG][IMP][13.0] rebase to include new linters
schout-it Oct 22, 2019
5f2534d
[FIX] report_xlsx: js
JoanSForgeFlow Dec 24, 2019
338ab87
[UPD] Update report_xlsx.pot
oca-travis Jan 8, 2020
1cb0efa
[UPD] README.rst
OCA-git-bot Jan 8, 2020
aff02b7
Update translation files
oca-transbot Jan 31, 2020
e6e30ec
[FIX] report_xlsx: rename a file
MiquelRForgeFlow Jan 29, 2020
e88a0b2
pre-commit update
OCA-git-bot Mar 14, 2020
ec19acc
report_xlsx 13.0.1.0.1
OCA-git-bot Apr 2, 2020
d5f4879
Update translation files
oca-transbot Aug 16, 2020
25f7c42
[IMP] : black, isort, prettier
tupaq Oct 19, 2020
b5c3e4d
[MIG] report_xlsx: Migration to 14.0
tupaq Oct 19, 2020
af1d1cf
[UPD] Update report_xlsx.pot
oca-travis Nov 25, 2020
f9262d9
[UPD] README.rst
OCA-git-bot Nov 25, 2020
21735bc
[FIX] safe_eval object time
Saran440 Dec 4, 2020
2791146
report_xlsx 14.0.1.0.1
OCA-git-bot Jan 13, 2021
ea9161c
Translated using Weblate (Spanish)
anasuarez1 Mar 16, 2021
e68b801
report_xlsx: bump development status [ci skip]
sbidoul Jun 2, 2021
eeb7195
[UPD] README.rst
OCA-git-bot Jun 2, 2021
d7bd2df
report_xlsx 14.0.1.0.2
OCA-git-bot Jun 2, 2021
3573d66
Translated using Weblate (Portuguese)
pedrocs-exo Jul 2, 2021
0e5877f
[IMP][FIX] report_xlsx: handle duplicate name exceptions
chienandalu Sep 17, 2021
78e1486
report_xlsx 14.0.1.0.3
OCA-git-bot Sep 20, 2021
162e20e
[FIX] report_xlsx: correctly handle exceptions, when generating report
em230418 Oct 27, 2021
1c2d08c
[UPD] README.rst
OCA-git-bot Nov 8, 2021
a135df1
report_xlsx 14.0.1.0.4
OCA-git-bot Nov 8, 2021
8e2c317
Added translation using Weblate (Swedish)
simonstromb Nov 17, 2021
869013d
Translated using Weblate (Swedish)
simonstromb Nov 30, 2021
7729e99
[MIG] report_xlsx: Migration to 15.0
JoanMForgeFlow Dec 7, 2021
49d0587
[FIX] report_xlsx: refactor controller and report hamdler
ChrisOForgeFlow Dec 7, 2021
a54fc81
[UPD] README.rst
OCA-git-bot Dec 11, 2021
b4c96ac
[UPD] Update report_xlsx.pot
Dec 11, 2021
cf4bead
[12.0][FIX] Report xlsx res_partner
Sep 10, 2019
12f79f4
report_xlsx 15.0.1.0.1
OCA-git-bot Dec 14, 2021
2124294
[FIX] report_xlsx: fix generation of pdf reports
MihranThalhath Jan 18, 2022
cc077c5
report_xlsx 15.0.1.0.3
OCA-git-bot Jan 18, 2022
544a1e4
report_xlsx
xavier-bouquiaux Feb 16, 2022
9935e28
report_xlsx 15.0.1.0.4
OCA-git-bot Feb 17, 2022
32cbfaa
[FIX]report_xlsx: development status tu mature
manuelregidor Apr 13, 2022
655cbef
[UPD] README.rst
OCA-git-bot Apr 13, 2022
69b3069
report_xlsx 15.0.1.0.5
OCA-git-bot Apr 13, 2022
ec24392
Added translation using Weblate (Catalan)
pablontura Apr 22, 2022
d3b0dfb
Translated using Weblate (Catalan)
pablontura Apr 22, 2022
9d9f676
[FIX] report_xlsx: Fix dynamic report download
JasminSForgeFlow Jun 24, 2022
fe36c54
report_xlsx 15.0.1.1.0
OCA-git-bot Aug 30, 2022
30f3f8d
[IMP] report_xlsx: Method for getting cell format for a currency
victoralmau Sep 2, 2022
a1e75a1
report_xlsx 15.0.1.1.1
OCA-git-bot Sep 8, 2022
04c225f
[MIG] Migrate report_xlsx to 16.0
RodrigoBM Nov 30, 2022
37fc60d
[UPD] Update report_xlsx.pot
Dec 4, 2022
9e063c8
[UPD] README.rst
OCA-git-bot Dec 4, 2022
c551221
[FIX] report_xlsx: add token in report_download() controller
alexis-via Dec 14, 2022
90b1b1b
report_xlsx 16.0.1.0.1
OCA-git-bot Dec 15, 2022
75e0b07
Translated using Weblate (Croatian)
badbole Jan 3, 2023
f2cb254
[FIX] report_xlsx: initialize reportname
ajaniszewska-dev Mar 10, 2023
3eda977
report_xlsx 16.0.1.0.2
OCA-git-bot Mar 18, 2023
04513ee
Translated using Weblate (Spanish)
Ivorra78 Aug 23, 2023
e2c00af
[UPD] README.rst
OCA-git-bot Sep 3, 2023
37b2dc9
[FIX] report_xlsx: Save as attachment
houzefa-abba Jun 6, 2023
da9b7fa
Update translation files
weblate Oct 10, 2023
599173e
[BOT] post-merge updates
OCA-git-bot Oct 10, 2023
dd185bb
[IMP] report_xlsx: pre-commit auto fixes
tien-ld Nov 22, 2023
9e4da58
[MIG] report_xlsx: Migration to 17.0
tien-ld Nov 22, 2023
adf9530
[FIX] migrated version number in __manifest__.py
gurneyalex Dec 8, 2023
08fd349
[UPD] Update report_xlsx.pot
Dec 8, 2023
869e7a1
[BOT] post-merge updates
OCA-git-bot Dec 8, 2023
2fd6da9
Translated using Weblate (Italian)
mymage Feb 12, 2024
ae2c417
Translated using Weblate (Swedish)
jakobkrabbe Jun 12, 2024
aaf16d5
[FIX] report_xlsx: Remove XML header in HTML
pedrobaeza Jul 17, 2024
f505bc3
[DOC] report_xlsx: Update USAGE.rst
amh-mw Apr 16, 2024
9e3f62e
[BOT] post-merge updates
OCA-git-bot Aug 19, 2024
d1496c1
[MIG] report_xlsx: Migration to 18.0
dariodelzozzo Sep 12, 2024
6da6e76
[UPD] Update report_xlsx.pot
Nov 6, 2024
1d95d34
[BOT] post-merge updates
OCA-git-bot Nov 6, 2024
cac5e79
Update translation files
weblate Nov 6, 2024
d033399
[FIX] *: align inherited method signature with odoo update
niyasraphy Aug 24, 2025
72d91c0
[BOT] post-merge updates
OCA-git-bot Aug 25, 2025
813c02f
Translated using Weblate (Turkish)
bo-eska Aug 25, 2025
20fd74c
Translated using Weblate (Turkish)
tsezgin Sep 10, 2025
78b1e49
[IMP] report_xlsx: pre-commit auto fixes
tupaq Oct 13, 2025
b4807cf
[MIG] report_xlsx: Migration to 19.0
tupaq Oct 13, 2025
2d42d09
[UPD] Update report_xlsx.pot
Oct 31, 2025
226e8d7
[BOT] post-merge updates
OCA-git-bot Oct 31, 2025
681b84f
[FIX] report_xlsx: Preserve custom context by using context from repo…
DucTruongKomit Nov 11, 2025
7b00d62
[BOT] post-merge updates
OCA-git-bot Nov 11, 2025
ebf784a
[FIX] report_xslx: Revert action_manager_report.esm.js to fix KeyErro…
alvaroGC-S73 Nov 18, 2025
87ce9b8
[BOT] post-merge updates
OCA-git-bot Nov 24, 2025
1bdadb1
Added translation using Weblate (Danish)
LauraVForgeFlow Jul 6, 2026
6360dac
Translated using Weblate (Danish)
LauraVForgeFlow Jul 6, 2026
0ce5f13
[IMP] report_xlsx: pre-commit auto fixes
propublisher01 Sep 28, 2026
b07289a
[MIG] report_xlsx: Migration to 20.0
propublisher01 Sep 28, 2026
3ec5150
rename module
luc-demeyer Apr 12, 2018
04a0b2a
xlsx formats
luc-demeyer Aug 5, 2018
7280a0c
improved error handling
luc-demeyer Aug 9, 2018
89669c5
autodetect boolean type
luc-demeyer Aug 10, 2018
07a798a
pylint: disable=old-api7-method-defined
luc-demeyer Aug 10, 2018
562ee20
pylint: disable=old-api7-method-defined
luc-demeyer Aug 10, 2018
b4a8cce
pylint W8112(eval-referenced)
luc-demeyer Aug 10, 2018
716ede0
pylint eval-used
luc-demeyer Aug 10, 2018
34427e7
add unit test
luc-demeyer Aug 12, 2018
6cd4e06
[UPD] Update report_xlsx_helper.pot
oca-travis Aug 14, 2018
d802d8a
[11.0][MIG] report_xlsx_helper: Migration to 11.0
luc-demeyer Sep 24, 2018
6d55754
add todo
luc-demeyer Sep 26, 2018
f5a1b65
[UPD] Update report_xlsx_helper.pot
oca-travis Oct 1, 2018
34331fe
[UPD] README.rst
OCA-git-bot Oct 2, 2018
45289dd
[10.0][FIX]fix _render for cell formats
luc-demeyer Nov 4, 2018
e52274c
[MIG] : Migration to 12.0
luc-demeyer Apr 21, 2019
e91d984
[UPD] README.rst
OCA-git-bot Jun 3, 2019
2eaa8a5
[UPD] Update report_xlsx_helper.pot
oca-travis Jun 3, 2019
073152b
[UPD] README.rst
OCA-git-bot Jul 31, 2019
d8b01cf
date to datetime conversion when autotyping
luc-demeyer Aug 7, 2019
829f737
greenify
luc-demeyer Aug 8, 2019
7dfecc7
increase test coverage
luc-demeyer Aug 10, 2019
d908136
[UPD] Update report_xlsx_helper.pot
oca-travis Oct 1, 2019
7711a6f
report_xlsx_helper 12.0.1.1.0
OCA-git-bot Oct 1, 2019
459b0d9
FIX error message when cellvalue's type is not recognized
ivantodorovich Sep 6, 2019
65211f9
report_xlsx_helper 12.0.1.1.1
OCA-git-bot Oct 10, 2019
4f918ee
[IMP] report_xlsx_helper: black, isort
kongrattapong Jan 9, 2020
6582601
[MIG] report_xlsx_helper: Migration to 13.0
kongrattapong Jan 9, 2020
2b9c6c6
[UPD] Update report_xlsx_helper.pot
oca-travis Feb 19, 2020
4352fc2
[UPD] README.rst
OCA-git-bot Feb 19, 2020
cfeeb49
report_xlsx_helper 13.0.1.0.1
OCA-git-bot Feb 19, 2020
5ba4513
[12.0][ENH] report_xlsx_helper : dynamic function _write_line
Saran440 Jan 22, 2020
453c643
greenify
luc-demeyer Feb 20, 2020
edf0bee
[UPD] README.rst
OCA-git-bot Feb 21, 2020
c0a6333
report_xlsx_helper 13.0.1.1.0
OCA-git-bot Feb 21, 2020
2678745
[14.0][MIG] report_xlsx_helper
Saran440 Nov 19, 2020
280b70f
[IMP] format xlsx to global files
Saran440 Nov 19, 2020
142f4eb
[UPD] Update report_xlsx_helper.pot
oca-travis Dec 2, 2020
49745e9
[FIX] report_xlsx_helper: force Libreoffice to recompute formulas
StefanRijnhart Feb 9, 2021
e52e1c6
Added translation using Weblate (Spanish)
anasuarez1 Mar 16, 2021
b40d33d
Translated using Weblate (Spanish)
anasuarez1 Mar 16, 2021
c9e7b2c
report_xlsx_helper 14.0.1.0.1
OCA-git-bot Nov 8, 2021
c1c81d9
[IMP] report_xlsx_helper: black, isort, prettier
sinerkiaid Jan 19, 2022
10fbb09
[MIG] report_xlsx_helper: Migration to 15.0
sinerkiaid Jan 19, 2022
28fda4d
[UPD] Update report_xlsx_helper.pot
Feb 20, 2022
d5f251d
[UPD] README.rst
OCA-git-bot Feb 20, 2022
4e77b68
[FIX]report_xlsx_helper: Development status mature
manuelregidor Apr 13, 2022
d12849c
[UPD] README.rst
OCA-git-bot Apr 13, 2022
77be2e3
report_xlsx_helper 15.0.1.0.1
OCA-git-bot Apr 13, 2022
546fe69
Added translation using Weblate (Catalan)
jabelchi Jun 15, 2022
223515b
Translated using Weblate (Catalan)
jabelchi Jun 15, 2022
d6664ea
[MIG] report_xlsx_helper: Migration to 16.0
RodrigoBM Oct 6, 2022
dcdb7ef
[UPD] Update report_xlsx_helper.pot
Dec 5, 2022
35a9a55
[UPD] README.rst
OCA-git-bot Dec 5, 2022
5fe4f54
Update translation files
weblate Dec 5, 2022
8690756
Translated using Weblate (Spanish)
Ivorra78 Jul 18, 2023
ab2ebfe
Translated using Weblate (Spanish)
Ivorra78 Aug 23, 2023
9f64b96
[UPD] README.rst
OCA-git-bot Sep 3, 2023
6e05437
Update translation files
weblate Oct 10, 2023
8b12352
Translated using Weblate (Spanish)
Ivorra78 Oct 15, 2023
bccb369
[IMP] report_xlsx_helper: pre-commit auto fixes
FernandoRomera Dec 20, 2023
730e42e
[17.0][MIG] report_xlsx_helper: Migration to 17.0
FernandoRomera Dec 20, 2023
5574e2a
[UPD] Update report_xlsx_helper.pot
Jan 23, 2024
ce9bd33
[BOT] post-merge updates
OCA-git-bot Jan 23, 2024
b06290a
Added translation using Weblate (Italian)
mymage Feb 5, 2024
fdcd2c2
Translated using Weblate (Italian)
mymage Feb 12, 2024
ed94edd
[FIX] *: line too long
pedrobaeza May 2, 2024
fca2153
[BOT] post-merge updates
OCA-git-bot May 2, 2024
2fc0ae5
Added translation using Weblate (French)
Nov 8, 2024
3a9460b
[IMP] report_xlsx_helper: pre-commit fixes
alexis-via Jan 3, 2025
12f7bb6
[MIG] report_xlsx_helper: migrate from v17 to v18
alexis-via Jan 3, 2025
1826418
[UPD] Update report_xlsx_helper.pot
Feb 10, 2025
8e0cd4c
[BOT] post-merge updates
OCA-git-bot Feb 10, 2025
8fe1c72
Added translation using Weblate (Turkish)
bo-eska Sep 8, 2025
2fa7393
Translated using Weblate (Turkish)
bo-eska Sep 8, 2025
6693d26
[MIG] report_xlsx_helper: Migration to 19.0
sergioM-S73 Nov 7, 2025
ae8dab9
[UPD] Update report_xlsx_helper.pot
Nov 26, 2025
915316a
[BOT] post-merge updates
OCA-git-bot Nov 26, 2025
5d66b51
[MIG] report_xlsx_helper: Migration to 20.0
alan196 Oct 10, 2026
b50f2fe
[IMP] report_xlsx_helper: pre-commit auto fixes
alan196 Oct 10, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
149 changes: 149 additions & 0 deletions report_xlsx/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
.. 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
================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:61af5f70a44c329b90fa1b3c7e98e743299c3bb6c1d8c385563d620f18d835e9
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Mature-brightgreen.png
:target: https://odoo-community.org/page/development-status
:alt: Mature
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
: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/20.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-20-0/reporting-engine-20-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=20.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

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

**Table of contents**

.. contents::
:local:

Installation
============

Make sure you have ``xlsxwriter`` Python module installed:

::

$ pip3 install xlsxwriter

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\`:

A python class :

::

from odoo import models

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``.

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>
<field name="report_type">xlsx</field>
<field name="report_name">module_name.report_name</field>
<field name="binding_model_id" ref="res.partner"/>
<field name="binding_type">report</field>
<field name="attachment_use" eval="False"/>
</record>

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:%2020.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.

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>
- Le Dinh Tien <tien-ld@komit-consulting.com>
- Marc Frankard <support@propublisher.be>

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

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/20.0/report_xlsx>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
5 changes: 5 additions & 0 deletions report_xlsx/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from . import controllers
from . import models
from . import report
21 changes: 21 additions & 0 deletions report_xlsx/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2015 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{
"name": "Base report xlsx",
"summary": "Base module to create xlsx report",
"author": "ACSONE SA/NV,Creu Blanca,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/reporting-engine",
"category": "Reporting",
"version": "20.0.1.0.0",
"development_status": "Mature",
"license": "AGPL-3",
"external_dependencies": {"python": ["xlsxwriter", "xlrd"]},
"depends": ["base", "web"],
"demo": ["demo/report.xml"],
"installable": True,
"assets": {
"web.assets_backend": [
"report_xlsx/static/src/js/report/action_manager_report.esm.js",
],
},
}
1 change: 1 addition & 0 deletions report_xlsx/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import main
103 changes: 103 additions & 0 deletions report_xlsx/controllers/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Copyright (C) 2017 Creu Blanca
# Copyright 2021 ForgeFlow S.L.
# License AGPL-3.0 or later (https://www.gnuorg/licenses/agpl.html).

import json
import logging

from werkzeug.urls import url_decode

from odoo.http import request, route
from odoo.http.dispatcher import serialize_exception as _serialize_exception
from odoo.http.stream import content_disposition
from odoo.tools import html_escape
from odoo.tools.safe_eval import safe_eval, time

from odoo.addons.web.controllers.report import ReportController

_logger = logging.getLogger(__name__)


class ReportController(ReportController):
@route()
def report_routes(self, reportname, docids=None, converter=None, **data):
if converter == "xlsx":
report = request.env["ir.actions.report"]._get_report_from_name(reportname)
context = dict(request.env.context)
if docids:
docids = [int(i) for i in docids.split(",")]
if data.get("options"):
data.update(json.loads(data.pop("options")))
if data.get("context"):
data["context"] = json.loads(data["context"])
context.update(data["context"])
xlsx = report.with_context(**context)._render_xlsx(
reportname, docids, data=data
)[0]
xlsxhttpheaders = [
(
"Content-Type",
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
),
("Content-Length", len(xlsx)),
]
return request.make_response(xlsx, headers=xlsxhttpheaders)
return super().report_routes(reportname, docids, converter, **data)

@route()
def report_download(self, data, context=None, token=None, readonly=True):
requestcontent = json.loads(data)
url, report_type = requestcontent[0], requestcontent[1]
if report_type == "xlsx":
try:
reportname = url.split("/report/xlsx/")[1].split("?")[0]
docids = None
if "/" in reportname:
reportname, docids = reportname.split("/")
if docids:
# Generic report:
response = self.report_routes(
reportname, docids=docids, converter="xlsx", context=context
)
else:
# Particular report:
data = dict(
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 = json.dumps({**context, **data_context})
response = self.report_routes(
reportname, converter="xlsx", context=context, **data
)

report = request.env["ir.actions.report"]._get_report_from_name(
reportname
)
filename = f"{report.name}.xlsx"

if docids:
ids = [int(x) for x in docids.split(",")]
obj = request.env[report.model].browse(ids)
if report.print_report_name and not len(obj) > 1:
report_name = safe_eval(
report.print_report_name, {"object": obj, "time": time}
)
filename = f"{report_name}.xlsx"
if not response.headers.get("Content-Disposition"):
response.headers.add(
"Content-Disposition", content_disposition(filename)
)
return response
except Exception as e:
_logger.exception("Error while generating report %s", reportname)
se = _serialize_exception(e)
error = {"code": 200, "message": "Odoo Server Error", "data": se}
return request.make_response(html_escape(json.dumps(error)))
else:
return super().report_download(
data, context, token=token, readonly=readonly
)
13 changes: 13 additions & 0 deletions report_xlsx/demo/report.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<!--
© 2017 Creu Blanca
License AGPL-3.0 or later (https://www.gnuorg/licenses/agpl.html).
-->
<record id="partner_xlsx" model="ir.actions.report">
<field name="name">Print to XLSX</field>
<field name="model">res.partner</field>
<field name="report_type">xlsx</field>
<field name="report_name">report_xlsx.partner_xlsx</field>
</record>
</odoo>
64 changes: 64 additions & 0 deletions report_xlsx/i18n/ca.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * report_xlsx
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2022-04-22 13:05+0000\n"
"Last-Translator: pablontura <pablo.ruiz@qubiq.es>\n"
"Language-Team: none\n"
"Language: ca\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.3.2\n"

#. module: report_xlsx
#: model:ir.model,name:report_xlsx.model_report_report_xlsx_abstract
msgid "Abstract XLSX Report"
msgstr "Informe XLSX abstracte"

#. module: report_xlsx
#: model:ir.model,name:report_xlsx.model_report_report_xlsx_partner_xlsx
msgid "Partner XLSX Report"
msgstr "Informe XLSX del soci"

#. module: report_xlsx
#: model:ir.actions.report,name:report_xlsx.partner_xlsx
msgid "Print to XLSX"
msgstr "Imprimeix a XLSX"

#. module: report_xlsx
#: model:ir.model,name:report_xlsx.model_ir_actions_report
msgid "Report Action"
msgstr "Informe d'acció"

#. module: report_xlsx
#: model:ir.model.fields,field_description:report_xlsx.field_ir_actions_report__report_type
msgid "Report Type"
msgstr "Tipus d'informe"

#. 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 ""
"El tipus d'informe que es renderà, cadascun amb el seu propi mètode de "
"representació. HTML significa que l'informe s'obrirà directament al vostre "
"navegador, PDF significa que l'informe es representarà amb Wkhtmltopdf i "
"l'usuari el baixarà."

#. module: report_xlsx
#: model:ir.model.fields.selection,name:report_xlsx.selection__ir_actions_report__report_type__xlsx
msgid "XLSX"
msgstr "XLSX"

#, python-format
#~ msgid "%s model was not found"
#~ msgstr "No s'ha trobat el model %s"
Loading
Loading