From d3b9953791ce98ec7355c4b16475888f14e77ec5 Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Mon, 1 Jun 2015 12:43:42 +0200 Subject: [PATCH] Add module report_xml. --- report_xml/README.rst | 82 + report_xml/__init__.py | 19 + report_xml/__openerp__.py | 32 + report_xml/controllers.py | 40 + report_xml/models.py | 70 + report_xml/static/description/icon.png | Bin 0 -> 4328 bytes report_xml/static/description/icon.svg | 3121 ++++++++++++++++++++++++ 7 files changed, 3364 insertions(+) create mode 100644 report_xml/README.rst create mode 100644 report_xml/__init__.py create mode 100644 report_xml/__openerp__.py create mode 100644 report_xml/controllers.py create mode 100644 report_xml/models.py create mode 100644 report_xml/static/description/icon.png create mode 100644 report_xml/static/description/icon.svg 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 AS59n3B5_s&=I5v_fjq$RC@1H zLs5iFM3w#VD=Yv2fZfOtVosag{&c2` zv=OtMW=WeEa9|@#CRz(&a*L+znK6d8H~`>6<)3~bo)LeSCKSZ$+u$wG?s$I}EDYf9 z@2>#&M&O_>7?=VY>+v^5^9l{b@dsoH$0K0?JS+e&8h}F9tfa`&Gy;D#y1sZ%G!|fh zb@2{@;}9;Q78tZQ4u#h2 z!=SNv1)QIUwkV)GevxLF|BqokEX?JPRZ&Yg3I;ItMFxs0D=MnnhhPI}5cB^aXiOj$ z?%|0C=;?{-;_+CxtM8v9@)n-7py(pu2$<;qyoLUEn;#5{MxkgN|HKG{ghOF8x;T() zpghh6q@th*a*DKT0{}SXjUc*~0a+W_fl0!Xp(LHnc1lk6?EI|0ospq1Fv{(!bF_@8 zLOjX`A|P|=NfnQD8NZC$r!`pR?dm+o^7Z5R z>0K8M)iKMz`Xgo>0HX?Iu$-%{E%mS5Mj*_*n}R2zR%S#B~;)&;x89X0`sT*)BYBR z>}fzBVEUg8hTYV@#BDNSA^3WGyBh2y0Lfb~=#CDibes&6xxpE~Q18s94SqH}AOb7V|S zTd$|5t?G=?VOrlfZm`TKHC5*N1;wrWm1gy#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6+do569yVx0-dHuwGMnxGuc$ma3fLte4|- zc>FQB@saU?c8!qflzwhmrS-z)^S>Y6C+tN~yW)l4fO6Fh--($h*kxY@W6y6UP{LU^ zsW~z+Yue$UsTa8%Y!L3=`pPv{>-*lPm8T_W z&@5*rdp^Ok^jYYc#27#8^WM_)MIj7Ep<=oc&OI zF1Xm9oD%yZP5YV3Ltov(?v5qIm?D(0@HpXv4CSB_60c87G4xR!+_GNR9s1V)Vws&i z;!J*ETt|R;*Xi7EYsj6wEjLV7k+0{NmWjRHX|r!<=l1{ZXE6KP{*Fg?tWYEy(l$+H z?;NmliG5v=HY$=59?abB6<6#}x{wjDwO6y`vmJg+FC`LvzKpCM%Q!wHbMo=CJNGBP zCs@@>j3`b%vCSM?)e@#K6n75|Jzz^`f0?j3^#M8uyX+&rp7=`HG=Lc=Xfe}siA84+ zPX}lI*9}5^ce*7hnIGzO&g2_vGy54=!>+farnWZqIwmaE{5yLOk3NLU-!-=D?7rt( z)^TT9#@i!W;#WKGr+-$Gi-OHc0!QkGYXR{e&gz<%-ajH|`4#V`RaYw|UQ;tWXk}#O zs|xUeex7oXd{#ZncP$6MSnF=+BT7hK z{W?n7^f%`v+P6L^h;K4+W<@e3q1iK5eU(7_Z@wCI+lVe + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +