fix: minor bugs in the print settings dialog and populate default print format field for a report
This commit is contained in:
parent
45c04a85ac
commit
820bc52201
3 changed files with 30 additions and 7 deletions
|
|
@ -83,10 +83,8 @@ class Report(Document):
|
|||
if self.report_type == "Report Builder":
|
||||
self.update_report_json()
|
||||
|
||||
if self.default_print_format:
|
||||
report_name = frappe.db.get_value("Print Format", self.default_print_format, "report")
|
||||
if not report_name or report_name != self.name:
|
||||
frappe.throw(_("Print Format must belong to this report!"))
|
||||
if self.default_print_format and self.has_value_changed("default_print_format"):
|
||||
self.validate_default_print_format()
|
||||
|
||||
def before_insert(self):
|
||||
self.set_doctype_roles()
|
||||
|
|
@ -414,6 +412,23 @@ class Report(Document):
|
|||
|
||||
return data
|
||||
|
||||
def validate_default_print_format(self):
|
||||
pf = frappe.db.get_value(
|
||||
"Print Format",
|
||||
self.default_print_format,
|
||||
["report", "print_format_for", "print_format_type", "disabled"],
|
||||
as_dict=True,
|
||||
)
|
||||
|
||||
if (
|
||||
not pf
|
||||
or pf.report != self.name
|
||||
or pf.print_format_for != "Report"
|
||||
or pf.print_format_type != "JS"
|
||||
or pf.disabled
|
||||
):
|
||||
frappe.throw(_("Selected Print Format is invalid for this Report."))
|
||||
|
||||
@frappe.whitelist()
|
||||
def toggle_disable(self, disable: bool):
|
||||
if not self.has_permission("write"):
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@ frappe.ui.get_print_settings = function (
|
|||
letter_head,
|
||||
pick_columns,
|
||||
has_filters = false,
|
||||
title = null
|
||||
title = null,
|
||||
default_print_format = null
|
||||
) {
|
||||
var print_settings = locals[":Print Settings"]["Print Settings"];
|
||||
|
||||
|
|
@ -31,6 +32,10 @@ frappe.ui.get_print_settings = function (
|
|||
fieldname: "print_format",
|
||||
label: __("Print Format"),
|
||||
options: "Print Format",
|
||||
default: default_print_format,
|
||||
description: __(
|
||||
"If no Print Format is selected, the default template for this report will be used."
|
||||
),
|
||||
get_query: () => ({
|
||||
filters: {
|
||||
print_format_for: "Report",
|
||||
|
|
@ -43,7 +48,7 @@ frappe.ui.get_print_settings = function (
|
|||
{
|
||||
fieldtype: "Check",
|
||||
fieldname: "with_letter_head",
|
||||
label: __("With Letter head"),
|
||||
label: __("With Letter Head"),
|
||||
},
|
||||
{
|
||||
fieldtype: "Link",
|
||||
|
|
@ -60,6 +65,7 @@ frappe.ui.get_print_settings = function (
|
|||
label: __("Include filters"),
|
||||
fieldtype: "Check",
|
||||
fieldname: "include_filters",
|
||||
depends_on: "eval: !doc.print_format",
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1941,7 +1941,9 @@ frappe.views.QueryReport = class QueryReport extends frappe.views.BaseList {
|
|||
(print_settings) => this.print_report(print_settings),
|
||||
this.report_doc.letter_head,
|
||||
this.get_visible_columns(),
|
||||
true
|
||||
true,
|
||||
null,
|
||||
this.report_doc.default_print_format
|
||||
);
|
||||
this.add_portrait_warning(dialog);
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue