Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 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
fd24cb7
[10.0] report_xlsx: Allow to define options for workbook creation (#98)
sbidoul Feb 22, 2017
2d500ab
[MIG] report_xlsx: Migration to 11.0
etobella Oct 25, 2017
6081314
[IMP] report_fillpdf, report_xlsx, report_xml: Use content_dispositio…
naglis Mar 11, 2018
5926056
Fix report_xlsx for printing from wizards
gdgellatly Aug 25, 2018
96458ad
[MIG] report_xlsx: Migration to 12.0
ovnicraft Oct 8, 2018
53690cf
[IMP] report_xlsx: README by fragments
pedrobaeza Dec 21, 2018
f0dd470
Translated using Weblate (German)
rschnapka Apr 24, 2019
2b5f992
[12.0][IMP] report_xlsx, make sure print_report_name works
kittiu Aug 9, 2019
5f418cc
Added translation using Weblate (Portuguese)
pedrocs-exo Aug 14, 2019
af659bf
[MIG] report_xlsx: Migration to 13.0
schout-it Oct 1, 2019
29f8685
[MIG][IMP][13.0] rebase to include new linters
schout-it Oct 22, 2019
d443185
[FIX] report_xlsx: js
JoanSForgeFlow Dec 24, 2019
1ebb600
[FIX] report_xlsx: rename a file
MiquelRForgeFlow Jan 29, 2020
ae5db4c
[IMP] : black, isort, prettier
tupaq Oct 19, 2020
82a0403
[MIG] report_xlsx: Migration to 14.0
tupaq Oct 19, 2020
23c227a
[FIX] safe_eval object time
Saran440 Dec 4, 2020
78baa58
Translated using Weblate (Spanish)
anasuarez1 Mar 16, 2021
bb605d6
report_xlsx: bump development status [ci skip]
sbidoul Jun 2, 2021
e276540
Translated using Weblate (Portuguese)
pedrocs-exo Jul 2, 2021
b3de4f5
[IMP][FIX] report_xlsx: handle duplicate name exceptions
chienandalu Sep 17, 2021
8f9c201
[FIX] report_xlsx: correctly handle exceptions, when generating report
em230418 Oct 27, 2021
4bfe8f3
Added translation using Weblate (Swedish)
simonstromb Nov 17, 2021
634e405
[MIG] report_xlsx: Migration to 15.0
JoanMForgeFlow Dec 7, 2021
28e63b8
[FIX] report_xlsx: refactor controller and report hamdler
ChrisOForgeFlow Dec 7, 2021
8c9e468
[12.0][FIX] Report xlsx res_partner
Sep 10, 2019
dab4622
[FIX] report_xlsx: fix generation of pdf reports
MihranThalhath Jan 18, 2022
92d5450
report_xlsx
xavier-bouquiaux Feb 16, 2022
6c7f909
[FIX]report_xlsx: development status tu mature
manuelregidor Apr 13, 2022
52f3f64
Added translation using Weblate (Catalan)
pablontura Apr 22, 2022
c165ca8
[FIX] report_xlsx: Fix dynamic report download
JasminSForgeFlow Jun 24, 2022
a5f9189
[IMP] report_xlsx: Method for getting cell format for a currency
victoralmau Sep 2, 2022
cad30f7
[MIG] Migrate report_xlsx to 16.0
RodrigoBM Nov 30, 2022
7061188
[FIX] report_xlsx: add token in report_download() controller
alexis-via Dec 14, 2022
0b61a0b
Translated using Weblate (Croatian)
badbole Jan 3, 2023
4129a4f
[FIX] report_xlsx: initialize reportname
ajaniszewska-dev Mar 10, 2023
2f2f593
Translated using Weblate (Spanish)
Ivorra78 Aug 23, 2023
607c055
[FIX] report_xlsx: Save as attachment
houzefa-abba Jun 6, 2023
7970cf3
[IMP] report_xlsx: pre-commit auto fixes
tien-ld Nov 22, 2023
0ab2482
[MIG] report_xlsx: Migration to 17.0
tien-ld Nov 22, 2023
775fae0
[FIX] migrated version number in __manifest__.py
gurneyalex Dec 8, 2023
916f30d
Translated using Weblate (Italian)
mymage Feb 12, 2024
a1999c8
Translated using Weblate (Swedish)
jakobkrabbe Jun 12, 2024
cbefb0c
[FIX] report_xlsx: Remove XML header in HTML
pedrobaeza Jul 17, 2024
1f670b2
[DOC] report_xlsx: Update USAGE.rst
amh-mw Apr 16, 2024
e95431f
[MIG] report_xlsx: Migration to 18.0
dariodelzozzo Sep 12, 2024
ee85669
[FIX] *: align inherited method signature with odoo update
niyasraphy Aug 24, 2025
3b9b50c
Translated using Weblate (Turkish)
bo-eska Aug 25, 2025
9d00c35
Translated using Weblate (Turkish)
tsezgin Sep 10, 2025
bba01f6
[IMP] report_xlsx: pre-commit auto fixes
tupaq Oct 13, 2025
07ed269
[MIG] report_xlsx: Migration to 19.0
tupaq Oct 13, 2025
aa56c2d
[FIX] report_xlsx: Preserve custom context by using context from repo…
DucTruongKomit Nov 11, 2025
b1d9e10
[FIX] report_xslx: Revert action_manager_report.esm.js to fix KeyErro…
alvaroGC-S73 Nov 18, 2025
0ec8348
Added translation using Weblate (Danish)
LauraVForgeFlow Jul 6, 2026
72c628d
[FIX]When set data in report_action function, the print_report_name d…
DucTruongKomit Nov 7, 2025
a90ac14
[FIX] report_xlsx: remove requiremnts already present in odoo
vincent-hatakeyama Oct 21, 2025
8463257
[IMP] report_xlsx: pre-commit auto fixes
propublisher01 Sep 28, 2026
831ef6b
[MIG] report_xlsx: Migration to 20.0
propublisher01 Nov 8, 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="base.model_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
20 changes: 20 additions & 0 deletions report_xlsx/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# 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",
"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
)
15 changes: 15 additions & 0 deletions report_xlsx/demo/report.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?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>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<field name="report_name">report_xlsx.partner_xlsx</field>
<field name="report_name">report_xlsx.partner_xlsx</field>
<field name="binding_model_id" ref="base.model_res_partner"/>
<field name="binding_type">report</field>

<field name="binding_model_id" ref="base.model_res_partner" />
<field name="binding_type">report</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