Any Report → Dot menu → Print or PDF, we get this Print Settings modal:
It seems an unnecessary step/friction to appear every time.
Is there any way to either:
a) hard-code values and skip the modal?
b) Write a custom button inside the Print view or elsewhere that invokes the Print/PDF with some passed parameters?
c) Any other way to smooth this step?
Many non-technical users complained about this modal, particularly for reports that are frequently printed.
I appreciate any input!
The “Print Settings” modal is triggered by the default Print menu item in query_report.js.
For specific reports, you can bypass it by adding a Quick Print button in the report’s onload, and (optionally) replacing the default menu item so users never see the dialog.
This keeps the change scoped to just the selected reports and doesn’t affect the global print flow.
———
Code Example (Report JS)
Add this in your report JS file (e.g. my_report.js):
frappe.query_reports["My Report Name"] = {
onload: function (report) {
const quick_print = function () {
const print_settings =
(locals[":Print Settings"] && locals[":Print Settings"]["Print Settings"]) || {};
const company = frappe.defaults.get_default("company");
let default_letter_head = "";
if (locals[":Company"] && locals[":Company"][company]) {
default_letter_head = locals[":Company"][company].default_letter_head || "";
}
const letter_head_name =
(report.report_doc && report.report_doc.letter_head) ||
default_letter_head ||
print_settings.letter_head ||
"";
const letter_head =
letter_head_name && frappe.boot && frappe.boot.letter_heads
? frappe.boot.letter_heads[letter_head_name]
: null;
const with_letter_head = Boolean(letter_head);
const settings = Object.assign({}, print_settings, {
orientation: "Landscape",
with_letter_head: with_letter_head ? 1 : 0,
with_letterhead: with_letter_head ? 1 : 0,
letter_head: letter_head,
include_filters: 0
});
report.print_report(settings); // no modal
};
// 1) Add a visible toolbar button
report.page.add_inner_button(__("Quick Print"), quick_print);
// 2) Replace the default menu item
if (Array.isArray(report.menu_items)) {
report.menu_items = report.menu_items.filter(
(item) => item.label !== __("Print")
);
report.menu_items.unshift({
label: __("Quick Print"),
action: quick_print,
standard: true
});
report.page.clear_menu();
report.set_menu_items();
}
}
};
———
Why this works
- report.print_report(settings) directly renders the report without opening the print settings modal.
- We reuse system defaults (Print Settings + Company letterhead) so behavior is consistent and safe.
Works well for me.
1 Like