mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-16 16:08:39 +00:00
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:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user