From 81575386c9482ff47d6e449f57f5376febb5c55d Mon Sep 17 00:00:00 2001 From: Akhil Narang Date: Thu, 20 Nov 2025 16:16:14 +0530 Subject: [PATCH] fix: use proper ifnull filter Signed-off-by: Akhil Narang --- frappe/custom/doctype/custom_field/custom_field.py | 4 ++-- frappe/desk/reportview.py | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) 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, )