diff --git a/report_xml/README.rst b/report_xml/README.rst new file mode 100644 index 00000000..0a3b88ab --- /dev/null +++ b/report_xml/README.rst @@ -0,0 +1,82 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :alt: License: AGPL-3 + +Qweb XML Reports +================ + +This module was written to extend the functionality of the reporting engine to +support XML reports and allow modules to generate them by code or by QWeb +templates. + +Installation +============ + +To install this module, you need to: + +* Install the repository `reporting-engine`_. + +Configuration +============= + +No manual configuration is needed. + +Usage +===== + +This module is technical, so its usage instructions are intended for module +developers. + +To use this module, you need to: + +* Create a module. +* Make it depend on this one. +* Follow `instructions to create reports`_ having in mind that the + ``report_type`` field in your ``ir.actions.report.xml`` record must be + ``qweb-xml``. + +In case you want to create a `custom report`_, the instructions remain the same +as for HTML reports, and the method that you must override is also called +``render_html``, even when this time you are creating a XML report. + +You can visit http:///report/xml// +to see your XML report online as a web page. + +For further information, please visit: + +* https://www.odoo.com/forum/help-1 +* https://github.com/OCA/reporting-engine + +Known issues / Roadmap +====================== + +None + +Credits +======= + +* Icon taken from http://commons.wikimedia.org/wiki/File:Text-xml.svg. + +Contributors +------------ + +* Jairo Llopis + +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 http://odoo-community.org. + + +.. _reporting-engine: https://github.com/OCA/reporting-engine +.. _instructions to create reports: https://www.odoo.com/documentation/8.0/reference/reports.html +.. _custom report: https://www.odoo.com/documentation/8.0/reference/reports.html#custom-reports diff --git a/report_xml/__init__.py b/report_xml/__init__.py new file mode 100644 index 00000000..809441f6 --- /dev/null +++ b/report_xml/__init__.py @@ -0,0 +1,19 @@ +# -*- encoding: utf-8 -*- + +# Odoo, Open Source Management Solution +# Copyright (C) 2014-2015 Grupo ESOC +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +from . import controllers, models diff --git a/report_xml/__openerp__.py b/report_xml/__openerp__.py new file mode 100644 index 00000000..ed9a6eeb --- /dev/null +++ b/report_xml/__openerp__.py @@ -0,0 +1,32 @@ +# -*- encoding: utf-8 -*- + +# Odoo, Open Source Management Solution +# Copyright (C) 2014-2015 Grupo ESOC +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +{ + "name": "Qweb XML Reports", + "version": "1.0", + "category": "Reporting", + "author": "Odoo Community Association (OCA), Grupo ESOC", + "license": "AGPL-3", + "website": "https://odoo-community.org/", + "installable": True, + "application": False, + "summary": "Allow to generate XML reports", + "depends": [ + "report", + ], +} diff --git a/report_xml/controllers.py b/report_xml/controllers.py new file mode 100644 index 00000000..a8ffb04f --- /dev/null +++ b/report_xml/controllers.py @@ -0,0 +1,40 @@ +# -*- encoding: utf-8 -*- + +# Odoo, Open Source Management Solution +# Copyright (C) 2014-2015 Grupo ESOC +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +from openerp.http import route +from openerp.addons.report.controllers import main as report + + +class ReportController(report.ReportController): + @route() + def report_routes(self, reportname, docids=None, converter=None, **data): + # Trick the main reporter to think we want an HTML report + new_converter = converter if converter != "xml" else "html" + response = super(ReportController, self).report_routes( + reportname, docids, new_converter, **data) + + # If it was an XML report, just download the generated response + if converter == "xml": + # XML header must be before any spaces, and it is a common error, + # so let's fix that here and make developers happier + response.data = response.data.strip() + + # XML files should be downloaded + response.headers.set("Content-Type", "text/xml") + + return response diff --git a/report_xml/models.py b/report_xml/models.py new file mode 100644 index 00000000..168e4de9 --- /dev/null +++ b/report_xml/models.py @@ -0,0 +1,70 @@ +# -*- encoding: utf-8 -*- + +# Odoo, Open Source Management Solution +# Copyright (C) 2014-2015 Grupo ESOC +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +from openerp import api, fields, models + + +class ReportAction(models.Model): + _inherit = "ir.actions.report.xml" + + report_type = fields.Selection(selection_add=[("qweb-xml", "XML")]) + + def _lookup_report(self, cr, name): + """Enable ``qweb-xml`` report lookup.""" + try: + super(ReportAction, self)._lookup_report(cr, name) + except Exception as ex: + # Somebody thought it was a good idea to use standard exceptions + if "qweb-xml" not in ex.message: + raise ex + else: + cr.execute( + "SELECT * FROM ir_act_report_xml WHERE report_name=%s", + (name,)) + return cr.dictfetchone()["report_name"] + + @api.model + def render_report(self, res_ids, name, data): + """Special handling for ``qweb-xml`` reports.""" + if data.get("report_type") == u"qweb-xml": + new_report = self._lookup_report(name) + recs = self.env[self.env.context["active_model"]].browse(res_ids) + result = self.env["report"].get_html(recs, new_report, data=data) + + # XML with spaces before the + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + July 2009 + + + Franziska Sponsel + + + + + Franziska Sponsel + + + + + RRZE + + + + + export + csv + text + + + + + Hendrik Eggers, Beate Kaspar + + + uses <http://ftp.uni-erlangen.de/pub/rrze/tango/rrze-icon-set/tango/scalable/emblems/report.svg> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +