forked from aeroo/aeroo_reports
/
qweb_action_manager.js
32 lines (29 loc) · 1.03 KB
/
qweb_action_manager.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/** @odoo-module */
import {registry} from "@web/core/registry";
async function cupsReportActionHandler(action, options, env) {
debugger;
if (action.report_type === "aeroo") {
const orm = env.services.orm;
const print_action = await orm.call(
"ir.actions.report",
"print_action_for_report_name",
[action.report_name]
);
if (print_action && print_action.action === "server") {
const result = await orm.call("ir.actions.report", "print_document", [
action.id,
action.context.active_ids,
action.data,
]);
if (result) {
env.services.notification.add(env._t("Successfully sent to printer!"));
} else {
env.services.notification.add(env._t("Could not sent to printer!"));
}
return true;
}
}
}
registry
.category("ir.actions.report handlers")
.add("cups_report_action_handler_aeroo", cupsReportActionHandler);