From 5fca8ad26f755616fd55ee4e20696ed8772e2723 Mon Sep 17 00:00:00 2001 From: Flectra Community Bot Date: Thu, 10 Jun 2021 07:18:51 +0000 Subject: [PATCH] Automatic Update form OCA2FC Migrator --- README.md | 4 ++-- report_xml/__manifest__.py | 2 +- report_xml/controllers/main.py | 19 ++++++++++++------- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 8154e93..b0d9b68 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Flectra Community / Flectra 2.0 / reporting-engine +# Flectra Community / reporting-engine None @@ -11,7 +11,7 @@ addon | version | summary --- | --- | --- [report_qweb_encrypt](report_qweb_encrypt/) | 2.0.1.0.0| Allow to encrypt qweb pdfs [report_xlsx_helper](report_xlsx_helper/) | 2.0.1.0.0| Report xlsx helpers -[report_xml](report_xml/) | 2.0.1.0.0| Allow to generate XML reports +[report_xml](report_xml/) | 2.0.1.0.1| Allow to generate XML reports [report_qweb_pdf_watermark](report_qweb_pdf_watermark/) | 2.0.1.0.0| Add watermarks to your QWEB PDF reports [report_xlsx_helper_demo](report_xlsx_helper_demo/) | 2.0.1.0.0| Report xlsx helpers - demo [base_comment_template](base_comment_template/) | 2.0.2.0.1| Add conditional mako template to any reporton models that inherits comment.template. diff --git a/report_xml/__manifest__.py b/report_xml/__manifest__.py index 96e0d7d..b49a86a 100644 --- a/report_xml/__manifest__.py +++ b/report_xml/__manifest__.py @@ -2,7 +2,7 @@ # License AGPL-3.0 or later (https://www.gnuorg/licenses/agpl.html). { "name": "XML Reports", - "version": "2.0.1.0.0", + "version": "2.0.1.0.1", "category": "Reporting", "website": "https://gitlab.com/flectra-community/reporting-engine", "author": "Tecnativa, Odoo Community Association (OCA), Avoin.Systems", diff --git a/report_xml/controllers/main.py b/report_xml/controllers/main.py index dd59bc9..0a07df3 100644 --- a/report_xml/controllers/main.py +++ b/report_xml/controllers/main.py @@ -6,7 +6,8 @@ import json from werkzeug.urls import url_decode from flectra.http import content_disposition, request, route, serialize_exception -from flectra.tools import html_escape, safe_eval +from flectra.tools import html_escape +from flectra.tools.safe_eval import safe_eval, time from flectra.addons.web.controllers import main as report @@ -41,7 +42,7 @@ class ReportController(report.ReportController): return super().report_routes(reportname, docids, converter, **data) @route() - def report_download(self, data, token): + def report_download(self, data, token, context=None): requestcontent = json.loads(data) url, report_type = requestcontent[0], requestcontent[1] if report_type == "qweb-xml": @@ -55,14 +56,18 @@ class ReportController(report.ReportController): if docids: # Generic report: response = self.report_routes( - reportname, docids=docids, converter="xml" + reportname, docids=docids, converter="xml", context=context ) else: # Particular report: # decoding the args represented in JSON - data = url_decode(url.split("?")[1]).items() + data = dict(url_decode(url.split("?")[1]).items()) + if "context" in data: + context = json.loads(context or "{}") + data_context = json.loads(data.pop("context")) + context = json.dumps({**context, **data_context}) response = self.report_routes( - reportname, converter="xml", **dict(data) + reportname, converter="xml", context=context, **data ) report_obj = request.env["ir.actions.report"] @@ -74,7 +79,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} + report.print_report_name, {"object": records, "time": time} ) filename = "{}.xml".format(report_name) response.headers.add( @@ -87,4 +92,4 @@ class ReportController(report.ReportController): error = {"code": 200, "message": "Flectra Server Error", "data": se} return request.make_response(html_escape(json.dumps(error))) else: - return super().report_download(data, token) + return super().report_download(data, token, context)