[IMP] base_report_to_printer: out of connection fallback to client

If the CUPS server isn't available the user won't be able to do anything
to print the report they need.

At last we can give them the chance to have a fallback behavior
downloading the document.

TT47134
This commit is contained in:
David
2024-01-31 13:02:02 +01:00
parent 6d5c1dd7c7
commit cb493cd596
4 changed files with 55 additions and 11 deletions

View File

@@ -10,19 +10,35 @@ async function cupsReportActionHandler(action, options, env) {
"print_action_for_report_name",
[action.report_name]
);
if (print_action && print_action.action === "server") {
if (
print_action &&
print_action.action === "server" &&
!print_action.printer_exception
) {
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!"));
env.services.notification.add(env._t("Successfully sent to printer!"), {
type: "success",
});
} else {
env.services.notification.add(env._t("Could not sent to printer!"));
env.services.notification.add(env._t("Could not sent to printer!"), {
type: "danger",
});
}
return true;
}
if (print_action.printer_exception) {
env.services.notification.add(
env._t("The printer couldn't be reached. Downloading document instead"),
{
type: "warning",
}
);
}
}
}