fix: use proper validations for number card validation method (#16581)
This commit is contained in:
parent
b41379c78b
commit
76a6c282b8
4 changed files with 25 additions and 11 deletions
|
|
@ -27,8 +27,11 @@ frappe.ui.form.on('Number Card', {
|
|||
frm.trigger('set_method_description');
|
||||
frm.trigger('render_filters_table');
|
||||
}
|
||||
frm.trigger('create_add_to_dashboard_button');
|
||||
frm.trigger('set_parent_document_type');
|
||||
|
||||
if (!frm.is_new()) {
|
||||
frm.trigger('create_add_to_dashboard_button');
|
||||
}
|
||||
},
|
||||
|
||||
create_add_to_dashboard_button: function(frm) {
|
||||
|
|
|
|||
|
|
@ -20,15 +20,24 @@ class NumberCard(Document):
|
|||
self.name = append_number_if_name_exists("Number Card", self.name)
|
||||
|
||||
def validate(self):
|
||||
if not self.document_type:
|
||||
frappe.throw(_("Document type is required to create a number card"))
|
||||
if self.type == "Document Type":
|
||||
if not (self.document_type and self.function):
|
||||
frappe.throw(_("Document Type and Function are required to create a number card"))
|
||||
|
||||
if (
|
||||
self.document_type
|
||||
and frappe.get_meta(self.document_type).istable
|
||||
and not self.parent_document_type
|
||||
):
|
||||
frappe.throw(_("Parent document type is required to create a number card"))
|
||||
if (
|
||||
self.document_type
|
||||
and frappe.get_meta(self.document_type).istable
|
||||
and not self.parent_document_type
|
||||
):
|
||||
frappe.throw(_("Parent Document Type is required to create a number card"))
|
||||
|
||||
elif self.type == "Report":
|
||||
if not (self.report_name and self.report_field and self.function):
|
||||
frappe.throw(_("Report Name, Report Field and Fucntion are required to create a number card"))
|
||||
|
||||
elif self.type == "Custom":
|
||||
if not self.method:
|
||||
frappe.throw(_("Method is required to create a number card"))
|
||||
|
||||
def on_update(self):
|
||||
if frappe.conf.developer_mode and self.is_standard:
|
||||
|
|
|
|||
|
|
@ -58,6 +58,8 @@ def get_report_doc(report_name):
|
|||
|
||||
|
||||
def get_report_result(report, filters):
|
||||
res = None
|
||||
|
||||
if report.report_type == "Query Report":
|
||||
res = report.execute_query_report(filters)
|
||||
|
||||
|
|
@ -84,7 +86,7 @@ def generate_report_result(
|
|||
res = get_report_result(report, filters) or []
|
||||
|
||||
columns, result, message, chart, report_summary, skip_total_row = ljust_list(res, 6)
|
||||
columns = [get_column_as_dict(col) for col in columns]
|
||||
columns = [get_column_as_dict(col) for col in (columns or [])]
|
||||
report_column_names = [col["fieldname"] for col in columns]
|
||||
|
||||
# convert to list of dicts
|
||||
|
|
|
|||
|
|
@ -249,7 +249,7 @@ frappe.dashboard_utils = {
|
|||
{args: values}
|
||||
).then(()=> {
|
||||
let dashboard_route_html =
|
||||
`<a href = "#dashboard/${values.dashboard}">${values.dashboard}</a>`;
|
||||
`<a href = "/app/dashboard/${values.dashboard}">${values.dashboard}</a>`;
|
||||
let message =
|
||||
__("{0} {1} added to Dashboard {2}", [doctype, values.name, dashboard_route_html]);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue