[MIG] report_xlsx: Migration to 15.0

pull/690/head
Joan Mateu Jordi 2021-12-07 12:36:12 +01:00 committed by Rodrigo
parent 58314d62c2
commit aec96ed82c
5 changed files with 24 additions and 38 deletions

View File

@ -6,12 +6,16 @@
"author": "ACSONE SA/NV," "Creu Blanca," "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/reporting-engine",
"category": "Reporting",
"version": "14.0.1.0.4",
"version": "15.0.1.0.0",
"development_status": "Production/Stable",
"license": "AGPL-3",
"external_dependencies": {"python": ["xlsxwriter", "xlrd"]},
"depends": ["base", "web"],
"data": ["views/webclient_templates.xml"],
"demo": ["demo/report.xml"],
"installable": True,
"assets": {
"web.assets_backend": [
"report_xlsx/static/src/js/report/action_manager_report.esm.js",
],
},
}

View File

@ -35,7 +35,7 @@ class ReportController(report.ReportController):
if data["context"].get("lang"):
del data["context"]["lang"]
context.update(data["context"])
xlsx = report.with_context(context)._render_xlsx(docids, data=data)[0]
xlsx = report.with_context(**context)._render_xlsx(docids, data=data)[0]
report_name = report.report_file
if report.print_report_name and not len(docids) > 1:
obj = request.env[report.model].browse(docids[0])

View File

@ -36,4 +36,4 @@ class ReportAction(models.Model):
("report_name", "=", report_name),
]
context = self.env["res.users"].context_get()
return report_obj.with_context(context).search(conditions, limit=1)
return report_obj.with_context(**context).search(conditions, limit=1)

View File

@ -1,16 +1,14 @@
// © 2017 Creu Blanca
// License AGPL-3.0 or later (https://www.gnuorg/licenses/agpl.html).
odoo.define("report_xlsx.report", function (require) {
"use strict";
/** @odoo-module **/
import {download} from "@web/core/network/download";
import {registry} from "@web/core/registry";
var core = require("web.core");
var ActionManager = require("web.ActionManager");
var framework = require("web.framework");
var session = require("web.session");
import core from "web.core";
import framework from "web.framework";
import session from "web.session";
var _t = core._t;
ActionManager.include({
_downloadReportXLSX: function (url, actions) {
async function _downloadReportXLSX(url, actions) {
var self = this;
framework.blockUI();
var type = "xlsx";
@ -59,9 +57,9 @@ odoo.define("report_xlsx.report", function (require) {
this.do_warn(_t("Warning"), message, true);
}
});
},
}
_triggerDownload: function (action, options, type) {
async function _triggerDownload (action, options, type) {
var self = this;
var reportUrls = this._makeReportUrls(action);
if (type === "xlsx") {
@ -79,20 +77,19 @@ odoo.define("report_xlsx.report", function (require) {
);
}
return this._super.apply(this, arguments);
},
}
_makeReportUrls: function (action) {
async function _makeReportUrls (action) {
var reportUrls = this._super.apply(this, arguments);
reportUrls.xlsx = "/report/xlsx/" + action.report_name;
return reportUrls;
},
}
_executeReportAction: function (action, options) {
async function _executeReportAction (action, options) {
var self = this;
if (action.report_type === "xlsx") {
return self._triggerDownload(action, options, "xlsx");
}
return this._super.apply(this, arguments);
},
});
});
}

View File

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<!--
© 2017 Creu Blanca
License AGPL-3.0 or later (https://www.gnuorg/licenses/agpl.html).
-->
<template id="assets_backend" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script
type="text/javascript"
src="/report_xlsx/static/src/js/report/action_manager_report.js"
/>
</xpath>
</template>
</odoo>