Files
Odoo-18.0-20251222/report_py3o/static/src/js/py3oactionservice.esm.js
tocmo0nlord adbe430761
Some checks failed
pre-commit / pre-commit (push) Has been cancelled
tests / Detect unreleased dependencies (push) Has been cancelled
tests / test with OCB (push) Has been cancelled
tests / test with Odoo (push) Has been cancelled
Initial commit: Odoo 18.0-20251222 extra-addons
2026-03-13 20:43:25 +00:00

56 lines
2.1 KiB
JavaScript

/** @odoo-module **/
import {download} from "@web/core/network/download";
import {registry} from "@web/core/registry";
registry
.category("ir.actions.report handlers")
.add("py3o_handler", async function (action, options, env) {
if (action.report_type === "py3o") {
let url = `/report/py3o/${action.report_name}`;
const actionContext = action.context || {};
if (
action.data === undefined ||
action.data === null ||
(typeof action.data === "object" &&
Object.keys(action.data).length === 0)
) {
// Build a query string with `action.data` (it's the place where reports
// using a wizard to customize the output traditionally put their options)
if (actionContext.active_ids) {
var activeIDsPath = "/" + actionContext.active_ids.join(",");
url += activeIDsPath;
}
} else {
var serializedOptionsPath =
"?options=" + encodeURIComponent(JSON.stringify(action.data));
serializedOptionsPath +=
"&context=" + encodeURIComponent(JSON.stringify(actionContext));
url += serializedOptionsPath;
}
env.services.ui.block();
try {
await download({
url: "/report/download",
data: {
data: JSON.stringify([url, action.report_type]),
context: JSON.stringify(action.context),
},
});
} finally {
env.services.ui.unblock();
}
const onClose = options.onClose;
if (action.close_on_report_download) {
return env.services.action.doAction(
{type: "ir.actions.act_window_close"},
{onClose}
);
} else if (onClose) {
onClose();
}
return Promise.resolve(true);
}
return Promise.resolve(false);
});