fix: accounting dimension search matching unrelated records

#56871 routed any searchfield without a DocField meta — including
"name", which get_search_fields() always appends — into the
`= cint(txt)` branch. For non-numeric search text cint() yields 0, so
`is_group = 0` (Cost Center) matched every leaf record on both
engines, and `name = 0` matched every non-numeric name on MariaDB.

Skip Check fields from or_filters entirely — a checkbox can't match
search text — and keep LIKE for everything else, including "name".
This commit is contained in:
Mihir Kandoi
2026-07-12 18:37:51 +05:30
parent 8db4f82af5
commit 38e8c3b1fe

View File

@@ -20,7 +20,7 @@ from frappe.query_builder.functions import (
Substring,
Sum,
)
from frappe.utils import cint, nowdate, today, unique
from frappe.utils import nowdate, today, unique
from pypika import Order
import erpnext
@@ -809,10 +809,8 @@ def get_filtered_dimensions(
for field in searchfields:
df = meta.get_field(field)
if df and df.fieldtype != "Check":
if not df or df.fieldtype != "Check":
or_filters.append([field, "LIKE", "%%%s%%" % txt])
else:
or_filters.append([field, "=", cint(txt)])
fields.append(field)
if dimension_filters: