-
-
Notifications
You must be signed in to change notification settings - Fork 918
[11.0] [MIG] report_xlsx #171
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
13 commits
Select commit
Hold shift + click to select a range
bad4bac
[CHG] Rename base_report_xlsx to report_xlsx and add xlsx report type…
ff0d718
[IMP] report_xlsx - Pass the report instance as well as ids of record…
sebalix deb1e7a
[IMP] report_xlsx - README updated
sebalix 6d37bd7
[FIX] report_xlsx - Fix lint
sebalix e6626a3
[CHG][report_xlsx] Bump version
6e63309
[FIX] report_xlsx - Minor fix
sebalix f5af118
Update README in report_xlsx
bealdav e6dd374
[MIG] Make modules uninstallable
pedrobaeza bd51541
[MIG] Rename manifest files
pedrobaeza c24f32e
[MIG] Migration of report_xlsx to 10.0 (#76)
0a77741
[10.0] report_xlsx: Allow to define options for workbook creation (#98)
sbidoul ef68ac8
OCA Transbot updated translations from Transifex
oca-transbot 692da64
[MIG] report_xlsx
etobella 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,90 @@ | ||
| .. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg | ||
| :target: https://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
| :alt: License: AGPL-3 | ||
|
|
||
| ================ | ||
| Base report xlsx | ||
| ================ | ||
|
|
||
| This module provides a basic report class to generate xlsx report. | ||
|
|
||
| Installation | ||
| ============ | ||
|
|
||
| Make sure you have ``xlsxwriter`` Python module installed:: | ||
|
|
||
| $ pip install xlsxwriter | ||
|
|
||
| For testing it is also necessary ``xlrd`` Python module installed:: | ||
|
|
||
| $ pip 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 :: | ||
|
|
||
| <report | ||
| id="partner_xlsx" | ||
| model="res.partner" | ||
| string="Print to XLSX" | ||
| report_type="xlsx" | ||
| name="module_name.report_name" | ||
| file="res_partner" | ||
| attachment_use="False" | ||
| /> | ||
|
|
||
| .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas | ||
| :alt: Try me on Runbot | ||
| :target: https://runbot.odoo-community.org/runbot/143/11.0 | ||
|
|
||
| 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 smashing it by providing a detailed and welcomed feedback. | ||
|
|
||
| Credits | ||
| ======= | ||
|
|
||
| Contributors | ||
| ------------ | ||
|
|
||
| * Adrien Peiffer <adrien.peiffer@acsone.eu> | ||
| * Enric Tobella <etobella@creublanca.es> | ||
|
|
||
| Maintainer | ||
| ---------- | ||
|
|
||
| .. image:: https://odoo-community.org/logo.png | ||
| :alt: Odoo Community Association | ||
| :target: https://odoo-community.org | ||
|
|
||
| This module is maintained by the OCA. | ||
|
|
||
| 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. | ||
|
|
||
| To contribute to this module, please visit https://odoo-community.org. | ||
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,31 @@ | ||
| # 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': "http://github.com/oca/reporting-engine", | ||
| 'category': 'Reporting', | ||
| 'version': '11.0.1.0.0', | ||
| 'license': 'AGPL-3', | ||
| 'external_dependencies': { | ||
| 'python': [ | ||
| 'xlsxwriter', | ||
| 'xlrd', | ||
| ], | ||
| }, | ||
| 'depends': [ | ||
| 'base', 'web', | ||
| ], | ||
| 'data': [ | ||
| 'views/webclient_templates.xml', | ||
| ], | ||
| 'demo': [ | ||
| 'demo/report.xml', | ||
| ], | ||
| 'installable': True, | ||
| } |
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,44 @@ | ||
| # Copyright (C) 2017 Creu Blanca | ||
| # License AGPL-3.0 or later (https://www.gnuorg/licenses/agpl.html). | ||
|
|
||
| from odoo.addons.web.controllers import main as report | ||
| from odoo.http import route, request | ||
|
|
||
| import json | ||
|
|
||
|
|
||
| class ReportController(report.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'): | ||
| # Ignore 'lang' here, because the context in data is the one | ||
| # from the webclient *but* if the user explicitely wants to | ||
| # change the lang, this mechanism overwrites it. | ||
| data['context'] = json.loads(data['context']) | ||
| if data['context'].get('lang'): | ||
| del data['context']['lang'] | ||
| context.update(data['context']) | ||
| xlsx = report.with_context(context).render_xlsx( | ||
| docids, data=data | ||
| )[0] | ||
| xlsxhttpheaders = [ | ||
| ('Content-Type', 'application/vnd.openxmlformats-' | ||
| 'officedocument.spreadsheetml.sheet'), | ||
| ('Content-Length', len(xlsx)), | ||
| ( | ||
| 'Content-Disposition', | ||
| 'attachment; filename=' + report.report_file + '.xlsx' | ||
| ) | ||
| ] | ||
| return request.make_response(xlsx, headers=xlsxhttpheaders) | ||
| return super(ReportController, self).report_routes( | ||
| reportname, docids, converter, **data | ||
| ) |
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,16 @@ | ||
| <?xml version="1.0" encoding="UTF-8" ?> | ||
| <odoo> | ||
| <!-- | ||
| © 2017 Creu Blanca | ||
| License AGPL-3.0 or later (https://www.gnuorg/licenses/agpl.html). | ||
| --> | ||
| <report | ||
| id="partner_xlsx" | ||
| model="res.partner" | ||
| string="Print to XLSX" | ||
| report_type="xlsx" | ||
| name="report_xlsx.partner_xlsx" | ||
| file="res_partner" | ||
| attachment_use="False" | ||
| /> | ||
| </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,24 @@ | ||
| # Translation of Odoo Server. | ||
| # This file contains the translation of the following modules: | ||
| # * report_xlsx | ||
| # | ||
| # Translators: | ||
| # Niki Waibel <niki.waibel@gmail.com>, 2016 | ||
| msgid "" | ||
| msgstr "" | ||
| "Project-Id-Version: Odoo Server 10.0\n" | ||
| "Report-Msgid-Bugs-To: \n" | ||
| "POT-Creation-Date: 2016-11-01 20:11+0000\n" | ||
| "PO-Revision-Date: 2016-11-01 20:11+0000\n" | ||
| "Last-Translator: Niki Waibel <niki.waibel@gmail.com>, 2016\n" | ||
| "Language-Team: German (https://www.transifex.com/oca/teams/23907/de/)\n" | ||
| "MIME-Version: 1.0\n" | ||
| "Content-Type: text/plain; charset=UTF-8\n" | ||
| "Content-Transfer-Encoding: \n" | ||
| "Language: de\n" | ||
| "Plural-Forms: nplurals=2; plural=(n != 1);\n" | ||
|
|
||
| #. module: report_xlsx | ||
| #: model:ir.model,name:report_xlsx.model_ir_actions_report_xml | ||
| msgid "ir.actions.report.xml" | ||
| msgstr "ir.actions.report.xml" |
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,24 @@ | ||
| # Translation of Odoo Server. | ||
| # This file contains the translation of the following modules: | ||
| # * report_xlsx | ||
| # | ||
| # Translators: | ||
| # Pedro M. Baeza <pedro.baeza@gmail.com>, 2016 | ||
| msgid "" | ||
| msgstr "" | ||
| "Project-Id-Version: Odoo Server 10.0\n" | ||
| "Report-Msgid-Bugs-To: \n" | ||
| "POT-Creation-Date: 2016-11-01 20:11+0000\n" | ||
| "PO-Revision-Date: 2016-11-01 20:11+0000\n" | ||
| "Last-Translator: Pedro M. Baeza <pedro.baeza@gmail.com>, 2016\n" | ||
| "Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n" | ||
| "MIME-Version: 1.0\n" | ||
| "Content-Type: text/plain; charset=UTF-8\n" | ||
| "Content-Transfer-Encoding: \n" | ||
| "Language: es\n" | ||
| "Plural-Forms: nplurals=2; plural=(n != 1);\n" | ||
|
|
||
| #. module: report_xlsx | ||
| #: model:ir.model,name:report_xlsx.model_ir_actions_report_xml | ||
| msgid "ir.actions.report.xml" | ||
| msgstr "ir.actions.report.xml" |
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,24 @@ | ||
| # Translation of Odoo Server. | ||
| # This file contains the translation of the following modules: | ||
| # * report_xlsx | ||
| # | ||
| # Translators: | ||
| # OCA Transbot <transbot@odoo-community.org>, 2017 | ||
| msgid "" | ||
| msgstr "" | ||
| "Project-Id-Version: Odoo Server 10.0\n" | ||
| "Report-Msgid-Bugs-To: \n" | ||
| "POT-Creation-Date: 2017-05-31 03:52+0000\n" | ||
| "PO-Revision-Date: 2017-05-31 03:52+0000\n" | ||
| "Last-Translator: OCA Transbot <transbot@odoo-community.org>, 2017\n" | ||
| "Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n" | ||
| "MIME-Version: 1.0\n" | ||
| "Content-Type: text/plain; charset=UTF-8\n" | ||
| "Content-Transfer-Encoding: \n" | ||
| "Language: fr\n" | ||
| "Plural-Forms: nplurals=2; plural=(n > 1);\n" | ||
|
|
||
| #. module: report_xlsx | ||
| #: model:ir.model,name:report_xlsx.model_ir_actions_report_xml | ||
| msgid "ir.actions.report.xml" | ||
| msgstr "ir.actions.report.xml" |
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,24 @@ | ||
| # Translation of Odoo Server. | ||
| # This file contains the translation of the following modules: | ||
| # * report_xlsx | ||
| # | ||
| # Translators: | ||
| # OCA Transbot <transbot@odoo-community.org>, 2017 | ||
| msgid "" | ||
| msgstr "" | ||
| "Project-Id-Version: Odoo Server 10.0\n" | ||
| "Report-Msgid-Bugs-To: \n" | ||
| "POT-Creation-Date: 2017-05-31 03:52+0000\n" | ||
| "PO-Revision-Date: 2017-05-31 03:52+0000\n" | ||
| "Last-Translator: OCA Transbot <transbot@odoo-community.org>, 2017\n" | ||
| "Language-Team: Croatian (https://www.transifex.com/oca/teams/23907/hr/)\n" | ||
| "MIME-Version: 1.0\n" | ||
| "Content-Type: text/plain; charset=UTF-8\n" | ||
| "Content-Transfer-Encoding: \n" | ||
| "Language: hr\n" | ||
| "Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" | ||
|
|
||
| #. module: report_xlsx | ||
| #: model:ir.model,name:report_xlsx.model_ir_actions_report_xml | ||
| msgid "ir.actions.report.xml" | ||
| msgstr "ir.actions.report.xml" |
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,24 @@ | ||
| # Translation of Odoo Server. | ||
| # This file contains the translation of the following modules: | ||
| # * report_xlsx | ||
| # | ||
| # Translators: | ||
| # Bole <bole@dajmi5.com>, 2016 | ||
| msgid "" | ||
| msgstr "" | ||
| "Project-Id-Version: Odoo Server 10.0\n" | ||
| "Report-Msgid-Bugs-To: \n" | ||
| "POT-Creation-Date: 2016-11-01 20:11+0000\n" | ||
| "PO-Revision-Date: 2016-11-01 20:11+0000\n" | ||
| "Last-Translator: Bole <bole@dajmi5.com>, 2016\n" | ||
| "Language-Team: Croatian (Croatia) (https://www.transifex.com/oca/teams/23907/hr_HR/)\n" | ||
| "MIME-Version: 1.0\n" | ||
| "Content-Type: text/plain; charset=UTF-8\n" | ||
| "Content-Transfer-Encoding: \n" | ||
| "Language: hr_HR\n" | ||
| "Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" | ||
|
|
||
| #. module: report_xlsx | ||
| #: model:ir.model,name:report_xlsx.model_ir_actions_report_xml | ||
| msgid "ir.actions.report.xml" | ||
| msgstr "ir.actions.report.xml" |
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,24 @@ | ||
| # Translation of Odoo Server. | ||
| # This file contains the translation of the following modules: | ||
| # * report_xlsx | ||
| # | ||
| # Translators: | ||
| # OCA Transbot <transbot@odoo-community.org>, 2017 | ||
| msgid "" | ||
| msgstr "" | ||
| "Project-Id-Version: Odoo Server 10.0\n" | ||
| "Report-Msgid-Bugs-To: \n" | ||
| "POT-Creation-Date: 2017-05-31 03:52+0000\n" | ||
| "PO-Revision-Date: 2017-05-31 03:52+0000\n" | ||
| "Last-Translator: OCA Transbot <transbot@odoo-community.org>, 2017\n" | ||
| "Language-Team: Italian (https://www.transifex.com/oca/teams/23907/it/)\n" | ||
| "MIME-Version: 1.0\n" | ||
| "Content-Type: text/plain; charset=UTF-8\n" | ||
| "Content-Transfer-Encoding: \n" | ||
| "Language: it\n" | ||
| "Plural-Forms: nplurals=2; plural=(n != 1);\n" | ||
|
|
||
| #. module: report_xlsx | ||
| #: model:ir.model,name:report_xlsx.model_ir_actions_report_xml | ||
| msgid "ir.actions.report.xml" | ||
| msgstr "ir.actions.report.xml" |
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,24 @@ | ||
| # Translation of Odoo Server. | ||
| # This file contains the translation of the following modules: | ||
| # * report_xlsx | ||
| # | ||
| # Translators: | ||
| # Peter Hageman <hageman.p@gmail.com>, 2017 | ||
| msgid "" | ||
| msgstr "" | ||
| "Project-Id-Version: Odoo Server 10.0\n" | ||
| "Report-Msgid-Bugs-To: \n" | ||
| "POT-Creation-Date: 2017-06-23 00:28+0000\n" | ||
| "PO-Revision-Date: 2017-06-23 00:28+0000\n" | ||
| "Last-Translator: Peter Hageman <hageman.p@gmail.com>, 2017\n" | ||
| "Language-Team: Dutch (Netherlands) (https://www.transifex.com/oca/teams/23907/nl_NL/)\n" | ||
| "MIME-Version: 1.0\n" | ||
| "Content-Type: text/plain; charset=UTF-8\n" | ||
| "Content-Transfer-Encoding: \n" | ||
| "Language: nl_NL\n" | ||
| "Plural-Forms: nplurals=2; plural=(n != 1);\n" | ||
|
|
||
| #. module: report_xlsx | ||
| #: model:ir.model,name:report_xlsx.model_ir_actions_report_xml | ||
| msgid "ir.actions.report.xml" | ||
| msgstr "ir.actions.report.xml" |
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,24 @@ | ||
| # Translation of Odoo Server. | ||
| # This file contains the translation of the following modules: | ||
| # * report_xlsx | ||
| # | ||
| # Translators: | ||
| # OCA Transbot <transbot@odoo-community.org>, 2017 | ||
| msgid "" | ||
| msgstr "" | ||
| "Project-Id-Version: Odoo Server 10.0\n" | ||
| "Report-Msgid-Bugs-To: \n" | ||
| "POT-Creation-Date: 2017-05-31 03:52+0000\n" | ||
| "PO-Revision-Date: 2017-05-31 03:52+0000\n" | ||
| "Last-Translator: OCA Transbot <transbot@odoo-community.org>, 2017\n" | ||
| "Language-Team: Portuguese (Portugal) (https://www.transifex.com/oca/teams/23907/pt_PT/)\n" | ||
| "MIME-Version: 1.0\n" | ||
| "Content-Type: text/plain; charset=UTF-8\n" | ||
| "Content-Transfer-Encoding: \n" | ||
| "Language: pt_PT\n" | ||
| "Plural-Forms: nplurals=2; plural=(n != 1);\n" | ||
|
|
||
| #. module: report_xlsx | ||
| #: model:ir.model,name:report_xlsx.model_ir_actions_report_xml | ||
| msgid "ir.actions.report.xml" | ||
| msgstr "ir.actions.report.xml" |
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.
I would suggest that you add your name as contributor