Skip to content

Commit

Permalink
Merge PR #443 into 14.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Nov 25, 2020
2 parents f25ed2d + 5231d53 commit 1f4a060
Show file tree
Hide file tree
Showing 35 changed files with 2,195 additions and 0 deletions.
127 changes: 127 additions & 0 deletions report_xlsx/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
================
Base report xlsx
================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-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/13.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-13-0/reporting-engine-13-0-report_xlsx
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/143/13.0
:alt: Try me on Runbot

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

<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"
/>

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 <https://github.com/OCA/reporting-engine/issues/new?body=module:%20report_xlsx%0Aversion:%2013.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 <[email protected]>
* Sébastien Alix <[email protected]>
* Stéphane Bidoul <[email protected]>
* Enric Tobella <[email protected]>
* Graeme Gellatly <[email protected]>
* Cristian Salamea <[email protected]>
* Rod Schouteden <[email protected]>

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/13.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
16 changes: 16 additions & 0 deletions report_xlsx/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# 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": "14.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,
}
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
50 changes: 50 additions & 0 deletions report_xlsx/controllers/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Copyright (C) 2017 Creu Blanca
# License AGPL-3.0 or later (https://www.gnuorg/licenses/agpl.html).

import json
import time

from odoo.http import content_disposition, request, route
from odoo.tools.safe_eval import safe_eval

from odoo.addons.web.controllers import main as report


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]
report_name = report.report_file
if report.print_report_name and not len(docids) > 1:
obj = request.env[report.model].browse(docids[0])
report_name = safe_eval(
report.print_report_name, {"object": obj, "time": time}
)
xlsxhttpheaders = [
(
"Content-Type",
"application/vnd.openxmlformats-"
"officedocument.spreadsheetml.sheet",
),
("Content-Length", len(xlsx)),
("Content-Disposition", content_disposition(report_name + ".xlsx")),
]
return request.make_response(xlsx, headers=xlsxhttpheaders)
return super(ReportController, self).report_routes(
reportname, docids, converter, **data
)
14 changes: 14 additions & 0 deletions report_xlsx/demo/report.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?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="report_file">res_partner</field>
</record>
</odoo>
124 changes: 124 additions & 0 deletions report_xlsx/i18n/de.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * report_xlsx
#
# Translators:
# Ricardo Gross <[email protected]>, 2017
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-12-23 03:49+0000\n"
"PO-Revision-Date: 2019-07-12 12:43+0000\n"
"Last-Translator: Maria Sparenberg <[email protected]>\n"
"Language-Team: German (https://www.transifex.com/oca/teams/23907/de/)\n"
"Language: de\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 3.7.1\n"

#. module: report_xlsx
#: code:addons/report_xlsx/models/ir_report.py:0
#, python-format
msgid "%s model was not found"
msgstr "%s Modell wurde nicht gefunden"

#. module: report_xlsx
#. openerp-web
#: code:addons/report_xlsx/static/src/js/report/action_manager_report.js:0
#, python-format
msgid ""
"A popup window with your report was blocked. You may need to change your "
"browser settings to allow popup windows for this page."
msgstr ""
"Ein Popup-Fenster wurde abgewiesen. Sie werden vermutlich Ihre Browser-"
"Einstellungen ändern müssen, damit die Anzeige dieser Seite möglich wird."

#. module: report_xlsx
#: model:ir.model,name:report_xlsx.model_report_report_xlsx_abstract
msgid "Abstract XLSX Report"
msgstr "Abstrakter XLSX-Bericht"

#. module: report_xlsx
#: 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 "Name anzeigen"

#. module: report_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 "ID"

#. module: report_xlsx
#: model:ir.model.fields,field_description:report_xlsx.field_report_report_xlsx_abstract____last_update
#: model:ir.model.fields,field_description:report_xlsx.field_report_report_xlsx_partner_xlsx____last_update
msgid "Last Modified on"
msgstr "Zuletzt geändert am"

#. module: report_xlsx
#: model:ir.model,name:report_xlsx.model_report_report_xlsx_partner_xlsx
#, fuzzy
msgid "Partner XLSX Report"
msgstr "Abstrakter XLSX-Bericht"

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

#. module: report_xlsx
#: model:ir.model,name:report_xlsx.model_ir_actions_report
msgid "Report Action"
msgstr "Berichtsaktion"

#. module: report_xlsx
#: model:ir.model.fields,field_description:report_xlsx.field_ir_actions_report__report_type
msgid "Report Type"
msgstr "Berichtsart"

#. 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 ""
"Die Art des Berichts, der erstellt wird, jeder mit eigener Darstellungsform. "
"HTML bedeutet, dass der Bericht unmittelbar in Ihrem Browser dargestellt "
"wird, PDF bedeutet, dass der Bericht mittels Wkhtmltopdf gewandelt wird und "
"vom Anwender heruntergeladen wird."

#. module: report_xlsx
#. openerp-web
#: code:addons/report_xlsx/static/src/js/report/action_manager_report.js:0
#, python-format
msgid "Warning"
msgstr "Hinweis"

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

#~ msgid "HTML"
#~ msgstr "HTML"

#~ msgid "PDF"
#~ msgstr "PDF"

#~ msgid "Py3o"
#~ msgstr "Py3o"

#~ msgid "Text"
#~ msgstr "Text"

#~ msgid "XML"
#~ msgstr "XML"

#~ msgid "report.report_xlsx.partner_xlsx"
#~ msgstr "report.report_xlsx.partner_xlsx"
Loading

0 comments on commit 1f4a060

Please sign in to comment.