Browse Source

Add module report_xml_sample.

pull/14/head
Jairo Llopis 10 years ago
parent
commit
7bd9510884
  1. 29
      report_xml/README.rst
  2. 69
      report_xml_sample/README.rst
  3. 19
      report_xml_sample/__init__.py
  4. 36
      report_xml_sample/__openerp__.py
  5. 39
      report_xml_sample/models.py
  6. BIN
      report_xml_sample/static/description/icon.png
  7. 3131
      report_xml_sample/static/description/icon.svg
  8. 43
      report_xml_sample/views/res_partner_templates.xml
  9. 22
      report_xml_sample/xsd/sample_report.xsd

29
report_xml/README.rst

@ -16,6 +16,9 @@ To install this module, you need to:
* Install lxml_ in Odoo's ``$PYTHONPATH``.
* Install the repository `reporting-engine`_.
But this module does nothing for the end user by itself, so if you have it
installed it's probably because there is another module that depends on it.
Configuration
=============
@ -24,10 +27,18 @@ No manual configuration is needed.
Usage
=====
This module is technical, so its usage instructions are intended for module
developers.
If you are a user
-----------------
You will be able to download XML reports from the *Print* menu found on form
and list views.
If you are a developer
----------------------
To use this module, you need to:
To learn from an example, just check the `sample module`_.
To develop with this module, you need to:
* Create a module.
* Make it depend on this one.
@ -39,11 +50,13 @@ 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://<server-address>/report/xml/<module.report_name>/<ids>
to see your XML report online as a web page.
You can make your custom report inherit ``report_xml.xsd_checked_report``, name
it like your XML ``<template>`` id prepended by ``report.``, add a ``xsd()``
method that returns a XSD in a string, and have XSD automatic checking for
free.
If you are a developer and you want a sample module to know how to use this
reporting engine, you can review `l10n_es_training`_.
You can visit ``http://<server-address>/report/xml/<module.report_name>/<ids>``
to see your XML report online as a web page.
For further information, please visit:
@ -84,5 +97,5 @@ To contribute to this module, please visit http://odoo-community.org.
.. _custom report: https://www.odoo.com/documentation/8.0/reference/reports.html#custom-reports
.. _instructions to create reports: https://www.odoo.com/documentation/8.0/reference/reports.html
.. _reporting-engine: https://github.com/OCA/reporting-engine
.. _l10n_es_training: https://github.com/grupoesoc/l10n-spain/tree/l10n_es_training/l10n_es_training
.. _sample module: https://github.com/OCA/reporting-engine/tree/8.0/report_xml_sample
.. _lxml: http://lxml.de/

69
report_xml_sample/README.rst

@ -0,0 +1,69 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:alt: License: AGPL-3
Qweb XML Reports Sample Module
==============================
This module was written to serve as a sample for developers that want to
generate Qweb XML reports in their modules. It is useless for the final user.
Installation
============
To install this module, you need to:
* Install lxml_ in Odoo's ``$PYTHONPATH``.
* Install the repository `reporting-engine`_.
Configuration
=============
No manual configuration is needed.
Usage
=====
Go to *Messaging > Organizer > Contacts*, enter any partner (or switch to *list
view* and select one or more of them), and under the *Print* menu download any
of the XML sample reports.
For further information, please visit:
* https://www.odoo.com/documentation/8.0/reference/qweb.html
* https://www.odoo.com/documentation/8.0/reference/reports.html
* 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 <j.llopis@grupoesoc.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 http://odoo-community.org.
.. _reporting-engine: https://github.com/OCA/reporting-engine
.. _lxml: http://lxml.de/

19
report_xml_sample/__init__.py

@ -0,0 +1,19 @@
# -*- encoding: utf-8 -*-
# Odoo, Open Source Management Solution
# Copyright (C) 2014-2015 Grupo ESOC <www.grupoesoc.es>
#
# 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 <http://www.gnu.org/licenses/>.
from . import models

36
report_xml_sample/__openerp__.py

@ -0,0 +1,36 @@
# -*- encoding: utf-8 -*-
# Odoo, Open Source Management Solution
# Copyright (C) 2014-2015 Grupo ESOC <www.grupoesoc.es>
#
# 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 <http://www.gnu.org/licenses/>.
{
"name": "Qweb XML Sample Report",
"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": "For developers who want an example",
"depends": [
"contacts",
"report",
],
"data": [
"views/res_partner_templates.xml",
]
}

39
report_xml_sample/models.py

@ -0,0 +1,39 @@
# -*- encoding: utf-8 -*-
# Odoo, Open Source Management Solution
# Copyright (C) 2014-2015 Grupo ESOC <www.grupoesoc.es>
#
# 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 <http://www.gnu.org/licenses/>.
from os import path
from openerp import api, models
class XSDSampleReport(models.AbstractModel):
"""This report is checked against an XSD before downloading.
The XML itself is declared in ``./views/res_partner_templates.xml``, and
the XSD can be found in ``./xsd/sample_report.xsd``.
This model's :attr:`._name` must be ``report.<XML ID of template>``.
"""
_name = "report.report_xml_sample.xsd_sample_report"
_inherit = "report_xml.xsd_checked_report"
@api.multi
def xsd(self):
"""Return the XSD schema contents."""
file = path.join(path.dirname(__file__), "xsd", "sample_report.xsd")
with open(file) as xsd:
return xsd.read()

BIN
report_xml_sample/static/description/icon.png

After

Width: 100  |  Height: 100  |  Size: 6.7 KiB

3131
report_xml_sample/static/description/icon.svg
File diff suppressed because it is too large
View File

43
report_xml_sample/views/res_partner_templates.xml

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- Basic XML report -->
<report
id="sample_report_action"
name="report_xml_sample.sample_report"
string="XML Report Sample"
report_type="qweb-xml"
model="res.partner"/>
<template id="sample_report">
<t t-call="report_xml.utf8_header">
<partners>
<partner t-foreach="docs" t-as="p">
<id t-esc="p.id"/>
<name t-esc="p.name"/>
<children t-if="p.child_ids">
<partner t-foreach="p.child_ids" t-as="c">
<id t-esc="c.id"/>
<name t-esc="c.name"/>
</partner>
</children>
</partner>
</partners>
</t>
</template>
<!-- Report checked against an XSD (see also ``../models.py``) -->
<report
id="xsd_sample_report_action"
name="report_xml_sample.xsd_sample_report"
string="XSD-Checked XML Report Sample"
report_type="qweb-xml"
model="res.partner"/>
<template id="xsd_sample_report">
<t t-call="report_xml_sample.sample_report"/>
</template>
</data>
</openerp>

22
report_xml_sample/xsd/sample_report.xsd

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- Complex types -->
<xs:complexType name="t_partners">
<xs:sequence>
<xs:element name="partner"
type="t_partner"
minOccurs="0"
maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="t_partner">
<xs:sequence>
<xs:element name="id" type="xs:int"/>
<xs:element name="name" type="xs:string"/>
<xs:element name="children" type="t_partners" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<!-- Schema -->
<xs:element name="partners" type="t_partners"/>
</xs:schema>
Loading…
Cancel
Save