From bf5d506637a0f74333310f1b8d0473b11254426e Mon Sep 17 00:00:00 2001 From: Kaushal Shriwas <64089478+kaulith@users.noreply.github.com> Date: Tue, 11 Aug 2026 11:58:33 +0530 Subject: [PATCH 1/2] fix(manufacturing): keep item code searchable when a barcode matches the same text --- erpnext/manufacturing/doctype/bom/mapper.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/erpnext/manufacturing/doctype/bom/mapper.py b/erpnext/manufacturing/doctype/bom/mapper.py index e237fcc4028..f237172fb56 100644 --- a/erpnext/manufacturing/doctype/bom/mapper.py +++ b/erpnext/manufacturing/doctype/bom/mapper.py @@ -158,9 +158,9 @@ def _item_query_filters(filters): def _item_query_or_filters(txt, searchfields, query_filters): if not txt: - return {} + return [] - or_filters = {s_field: ("like", f"%{txt}%") for s_field in searchfields} + or_filters = [[s_field, "like", f"%{txt}%"] for s_field in searchfields] barcodes = frappe.get_all( "Item Barcode", fields=["parent as item_code"], @@ -169,7 +169,7 @@ def _item_query_or_filters(txt, searchfields, query_filters): ) barcode_codes = [d.item_code for d in barcodes] if barcode_codes: - or_filters["name"] = ("in", barcode_codes) + or_filters.append(["name", "in", barcode_codes]) return or_filters From 23024d1ea91ed7e1b5cd9e658e468d18a42af411 Mon Sep 17 00:00:00 2001 From: Kaushal Shriwas <64089478+kaulith@users.noreply.github.com> Date: Tue, 11 Aug 2026 11:58:36 +0530 Subject: [PATCH 2/2] test(manufacturing): cover BOM item search when item code collides with a barcode --- erpnext/manufacturing/doctype/bom/test_bom.py | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/erpnext/manufacturing/doctype/bom/test_bom.py b/erpnext/manufacturing/doctype/bom/test_bom.py index 6d45e7452b2..5147a0809d9 100644 --- a/erpnext/manufacturing/doctype/bom/test_bom.py +++ b/erpnext/manufacturing/doctype/bom/test_bom.py @@ -530,6 +530,29 @@ class TestBOM(ERPNextTestSuite): self.assertNotEqual(len(test_items), len(filtered), msg="Item filtering showing excessive results") self.assertTrue(0 < len(filtered) <= 3, msg="Item filtering showing excessive results") + @timeout + def test_bom_item_query_matches_item_code_colliding_with_another_barcode(self): + item = make_item( + "_Test BOM Query 2.5MM", + {"is_stock_item": 1, "item_name": "_Test BOM Query Sheet", "description": "sheet"}, + ) + make_item( + "_Test BOM Query Barcode Holder", + {"is_stock_item": 1}, + barcode=f"90{item.name}90", + ) + + results = item_query( + doctype="Item", + txt=item.name, + searchfield="name", + start=0, + page_len=20, + filters={"is_stock_item": 1}, + ) + + self.assertIn(item.name, [d[0] for d in results]) + @timeout def test_exclude_exploded_items_from_bom(self): bom_no = get_default_bom()