mirror of
https://github.com/OCA/report-print-send.git
synced 2025-02-16 07:11:31 +02:00
[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:
@@ -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",
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user