Repository navigation
[20.0][MIG] report_xlsx: Migration to 20.0 #1203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
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…
fc73124
[IMP] report_xlsx - Pass the report instance as well as ids of record…
sebalix 1a68ac0
[MIG] Migration of report_xlsx to 10.0 (#76)
fd24cb7
[10.0] report_xlsx: Allow to define options for workbook creation (#98)
sbidoul 2d500ab
[MIG] report_xlsx: Migration to 11.0
etobella 6081314
[IMP] report_fillpdf, report_xlsx, report_xml: Use content_dispositio…
naglis 5926056
Fix report_xlsx for printing from wizards
gdgellatly 96458ad
[MIG] report_xlsx: Migration to 12.0
ovnicraft 53690cf
[IMP] report_xlsx: README by fragments
pedrobaeza f0dd470
Translated using Weblate (German)
rschnapka 2b5f992
[12.0][IMP] report_xlsx, make sure print_report_name works
kittiu 5f418cc
Added translation using Weblate (Portuguese)
pedrocs-exo af659bf
[MIG] report_xlsx: Migration to 13.0
schout-it 29f8685
[MIG][IMP][13.0] rebase to include new linters
schout-it d443185
[FIX] report_xlsx: js
JoanSForgeFlow 1ebb600
[FIX] report_xlsx: rename a file
MiquelRForgeFlow ae5db4c
[IMP] : black, isort, prettier
tupaq 82a0403
[MIG] report_xlsx: Migration to 14.0
tupaq 23c227a
[FIX] safe_eval object time
Saran440 78baa58
Translated using Weblate (Spanish)
anasuarez1 bb605d6
report_xlsx: bump development status [ci skip]
sbidoul e276540
Translated using Weblate (Portuguese)
pedrocs-exo b3de4f5
[IMP][FIX] report_xlsx: handle duplicate name exceptions
chienandalu 8f9c201
[FIX] report_xlsx: correctly handle exceptions, when generating report
em230418 4bfe8f3
Added translation using Weblate (Swedish)
simonstromb 634e405
[MIG] report_xlsx: Migration to 15.0
JoanMForgeFlow 28e63b8
[FIX] report_xlsx: refactor controller and report hamdler
ChrisOForgeFlow 8c9e468
[12.0][FIX] Report xlsx res_partner
dab4622
[FIX] report_xlsx: fix generation of pdf reports
MihranThalhath 92d5450
report_xlsx
xavier-bouquiaux 6c7f909
[FIX]report_xlsx: development status tu mature
manuelregidor 52f3f64
Added translation using Weblate (Catalan)
pablontura c165ca8
[FIX] report_xlsx: Fix dynamic report download
JasminSForgeFlow a5f9189
[IMP] report_xlsx: Method for getting cell format for a currency
victoralmau cad30f7
[MIG] Migrate report_xlsx to 16.0
RodrigoBM 7061188
[FIX] report_xlsx: add token in report_download() controller
alexis-via 0b61a0b
Translated using Weblate (Croatian)
badbole 4129a4f
[FIX] report_xlsx: initialize reportname
ajaniszewska-dev 2f2f593
Translated using Weblate (Spanish)
Ivorra78 607c055
[FIX] report_xlsx: Save as attachment
houzefa-abba 7970cf3
[IMP] report_xlsx: pre-commit auto fixes
tien-ld 0ab2482
[MIG] report_xlsx: Migration to 17.0
tien-ld 775fae0
[FIX] migrated version number in __manifest__.py
gurneyalex 916f30d
Translated using Weblate (Italian)
mymage a1999c8
Translated using Weblate (Swedish)
jakobkrabbe cbefb0c
[FIX] report_xlsx: Remove XML header in HTML
pedrobaeza 1f670b2
[DOC] report_xlsx: Update USAGE.rst
amh-mw e95431f
[MIG] report_xlsx: Migration to 18.0
dariodelzozzo ee85669
[FIX] *: align inherited method signature with odoo update
niyasraphy 3b9b50c
Translated using Weblate (Turkish)
bo-eska 9d00c35
Translated using Weblate (Turkish)
tsezgin bba01f6
[IMP] report_xlsx: pre-commit auto fixes
tupaq 07ed269
[MIG] report_xlsx: Migration to 19.0
tupaq aa56c2d
[FIX] report_xlsx: Preserve custom context by using context from repo…
DucTruongKomit b1d9e10
[FIX] report_xslx: Revert action_manager_report.esm.js to fix KeyErro…
alvaroGC-S73 0ec8348
Added translation using Weblate (Danish)
LauraVForgeFlow 72c628d
[FIX]When set data in report_action function, the print_report_name d…
DucTruongKomit a90ac14
[FIX] report_xlsx: remove requiremnts already present in odoo
vincent-hatakeyama 8463257
[IMP] report_xlsx: pre-commit auto fixes
propublisher01 831ef6b
[MIG] report_xlsx: Migration to 20.0
propublisher01 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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", | ||
| ], | ||
| }, | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| from . import main |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> | ||
| <field name="binding_model_id" ref="base.model_res_partner" /> | ||
| <field name="binding_type">report</field> | ||
| </record> | ||
| </odoo> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.