mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-30 07:08:24 +00:00
Merge pull request #58001 from frappe/mergify/bp/version-15-hotfix/pr-57997
fix: keep item code searchable when a barcode matches the same text (backport #57997)
This commit is contained in:
@@ -1577,10 +1577,10 @@ def item_query(doctype, txt, searchfield, start, page_len, filters):
|
|||||||
|
|
||||||
query_filters = {"disabled": 0, "ifnull(end_of_life, '3099-12-31')": (">", today())}
|
query_filters = {"disabled": 0, "ifnull(end_of_life, '3099-12-31')": (">", today())}
|
||||||
|
|
||||||
or_cond_filters = {}
|
or_cond_filters = []
|
||||||
if txt:
|
if txt:
|
||||||
for s_field in searchfields:
|
for s_field in searchfields:
|
||||||
or_cond_filters[s_field] = ("like", f"%{txt}%")
|
or_cond_filters.append([s_field, "like", f"%{txt}%"])
|
||||||
|
|
||||||
barcodes = frappe.get_all(
|
barcodes = frappe.get_all(
|
||||||
"Item Barcode",
|
"Item Barcode",
|
||||||
@@ -1590,7 +1590,7 @@ def item_query(doctype, txt, searchfield, start, page_len, filters):
|
|||||||
|
|
||||||
barcodes = [d.item_code for d in barcodes]
|
barcodes = [d.item_code for d in barcodes]
|
||||||
if barcodes:
|
if barcodes:
|
||||||
or_cond_filters["name"] = ("in", barcodes)
|
or_cond_filters.append(["name", "in", barcodes])
|
||||||
|
|
||||||
if filters and filters.get("item_code"):
|
if filters and filters.get("item_code"):
|
||||||
has_variants = frappe.get_cached_value("Item", filters.get("item_code"), "has_variants")
|
has_variants = frappe.get_cached_value("Item", filters.get("item_code"), "has_variants")
|
||||||
|
|||||||
@@ -461,6 +461,29 @@ class TestBOM(FrappeTestCase):
|
|||||||
self.assertNotEqual(len(test_items), len(filtered), msg="Item filtering showing excessive results")
|
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")
|
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
|
@timeout
|
||||||
def test_exclude_exploded_items_from_bom(self):
|
def test_exclude_exploded_items_from_bom(self):
|
||||||
bom_no = get_default_bom()
|
bom_no = get_default_bom()
|
||||||
|
|||||||
Reference in New Issue
Block a user