diff --git a/frappe/custom/doctype/custom_field/custom_field.py b/frappe/custom/doctype/custom_field/custom_field.py index 722cc29c54..f75dfbd58f 100644 --- a/frappe/custom/doctype/custom_field/custom_field.py +++ b/frappe/custom/doctype/custom_field/custom_field.py @@ -9,7 +9,7 @@ from frappe.custom.doctype.property_setter.property_setter import delete_propert from frappe.model import core_doctypes_list from frappe.model.docfield import supports_translation from frappe.model.document import Document -from frappe.query_builder.functions import IfNull +from frappe.query_builder import Field, functions from frappe.utils import cstr, random_string @@ -285,7 +285,7 @@ def get_fields_label(doctype=None): def create_custom_field_if_values_exist(doctype, df): df = frappe._dict(df) if df.fieldname in frappe.db.get_table_columns(doctype) and frappe.db.count( - dt=doctype, filters=IfNull(df.fieldname, "") != "" + dt=doctype, filters=functions.IfNull(Field(df.fieldname), "") != "" ): create_custom_field(doctype, df) diff --git a/frappe/desk/reportview.py b/frappe/desk/reportview.py index 7af8008965..c779277b9e 100644 --- a/frappe/desk/reportview.py +++ b/frappe/desk/reportview.py @@ -738,10 +738,12 @@ def get_filter_dashboard_data(stats, doctype, filters=None): continue tagcount = [] if tag["type"] not in ["Date", "Datetime"]: + from frappe.query_builder import Field, functions + tagcount = frappe.get_list( doctype, fields=[tag["name"], {"COUNT": "*"}], - filters=[*filters, "ifnull(`{}`,'')!=''".format(tag["name"])], + filters=[*filters, functions.IfNull(Field(tag["name"]), "") != ""], group_by=tag["name"], as_list=True, )