Browse Source

[MIG] report_xml: Migration to 14.0

myc-14.0-py3o
Francisco Ivan Anton Prieto 3 years ago
committed by Enric Tobella
parent
commit
98262b1445
  1. 1
      report_xml/README.rst
  2. 2
      report_xml/__manifest__.py
  3. 5
      report_xml/controllers/main.py
  4. 19
      report_xml/demo/report.xml
  5. 6
      report_xml/models/ir_actions_report.py
  6. 1
      report_xml/readme/CONTRIBUTORS.rst
  7. 2
      report_xml/reports/report_report_xml_abstract.py
  8. 2
      report_xml/tests/test_report_xml.py

1
report_xml/README.rst

@ -120,6 +120,7 @@ Contributors
* Jairo Llopis
* `Avoin.Systems <https://avoin.systems/>`_:
* Tatiana Deribina
* Iván Antón <ozono@ozonomultimedia.com>
Other credits
~~~~~~~~~~~~~

2
report_xml/__manifest__.py

@ -2,7 +2,7 @@
# License AGPL-3.0 or later (https://www.gnuorg/licenses/agpl.html).
{
"name": "XML Reports",
"version": "13.0.1.0.0",
"version": "14.0.1.0.0",
"category": "Reporting",
"website": "https://github.com/OCA/reporting-engine",
"author": "Tecnativa, Odoo Community Association (OCA), Avoin.Systems",

5
report_xml/controllers/main.py

@ -2,7 +2,6 @@
# License AGPL-3.0 or later (https://www.gnuorg/licenses/agpl.html).
import json
import time
from werkzeug.urls import url_decode
@ -32,7 +31,7 @@ class ReportController(report.ReportController):
del data["context"]["lang"]
context.update(data["context"])
xml = report.with_context(context).render_qweb_xml(docids, data=data)[0]
xml = report.with_context(context)._render_qweb_xml(docids, data=data)[0]
xmlhttpheaders = [
("Content-Type", "text/xml"),
("Content-Length", len(xml)),
@ -75,7 +74,7 @@ class ReportController(report.ReportController):
records = request.env[report.model].browse(ids)
if report.print_report_name and not len(records) > 1:
report_name = safe_eval(
report.print_report_name, {"object": records, "time": time}
report.print_report_name, {"object": records}
)
filename = "{}.xml".format(report_name)
response.headers.add(

19
report_xml/demo/report.xml

@ -1,19 +1,16 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<report
id="demo_xml_report"
name="report_xml.demo_report_xml_view"
string="Demo xml report"
report_type="qweb-xml"
print_report_name="'Demo xml report'"
model="res.company"
/>
<!--
<record id="demo_xml_report" model="ir.actions.report">
<field name="name">Demo xml report</field>
<field name="model">res.company</field>
<field name="report_type">qweb-xml</field>
<field name="report_name">report_xml.demo_report_xml_view</field>
<field name="report_file">res_company</field>
<!--
In case of demo data next definition will not work. So it just example
how it should look. If report is a part of demo data you will need
add file to report instance via `post_install_hook`
-->
<record id="demo_xml_report" model="ir.actions.report">
-->
<field name="xsd_schema" type="base64" file="report_xml/demo/demo_report.xsd" />
</record>
</odoo>

6
report_xml/models/ir_actions_report.py

@ -7,7 +7,9 @@ from odoo import fields, models
class IrActionsReport(models.Model):
_inherit = "ir.actions.report"
report_type = fields.Selection(selection_add=[("qweb-xml", "XML")])
report_type = fields.Selection(
selection_add=[("qweb-xml", "XML")], ondelete={"qweb-xml": "set default"}
)
xsd_schema = fields.Binary(
string="XSD Validation Schema",
attachment=True,
@ -34,7 +36,7 @@ class IrActionsReport(models.Model):
),
)
def render_qweb_xml(self, docids, data=None):
def _render_qweb_xml(self, docids, data=None):
"""
Call `generate_report` method of report abstract class
`report.<report technical name>` or of standard class for XML report

1
report_xml/readme/CONTRIBUTORS.rst

@ -3,3 +3,4 @@
* Jairo Llopis
* `Avoin.Systems <https://avoin.systems/>`_:
* Tatiana Deribina
* Iván Antón <ozono@ozonomultimedia.com>

2
report_xml/reports/report_report_xml_abstract.py

@ -51,7 +51,7 @@ class ReportXmlAbstract(models.AbstractModel):
data = ir_report._get_rendering_context(docids, data)
# render template
result_bin = ir_report.render_template(ir_report.report_name, data)
result_bin = ir_report._render_template(ir_report.report_name, data)
# prettify result content
# normalize indents

2
report_xml/tests/test_report_xml.py

@ -13,7 +13,7 @@ class TestXmlReport(common.TransactionCase):
report = report_object._get_report_from_name(report_name)
docs = self.env["res.company"].search([], limit=1)
self.assertEqual(report.report_type, "qweb-xml")
result_report = report.render(docs.ids, {})
result_report = report._render(docs.ids, {})
result_tree = etree.fromstring(result_report[0])
el = result_tree.xpath("/root/user/name")
self.assertEqual(el[0].text, docs.ensure_one().name)
Loading…
Cancel
Save