From 729fc738af7d78a6f75cb0f794f4c4451d74cd05 Mon Sep 17 00:00:00 2001 From: s-aga-r Date: Tue, 28 Nov 2023 11:08:52 +0530 Subject: [PATCH 1/2] fix: product bundle search input --- .../doctype/product_bundle/product_bundle.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/erpnext/selling/doctype/product_bundle/product_bundle.py b/erpnext/selling/doctype/product_bundle/product_bundle.py index 2fd9cc130125..c934f0dffa5d 100644 --- a/erpnext/selling/doctype/product_bundle/product_bundle.py +++ b/erpnext/selling/doctype/product_bundle/product_bundle.py @@ -76,16 +76,19 @@ def validate_child_items(self): @frappe.validate_and_sanitize_search_inputs def get_new_item_code(doctype, txt, searchfield, start, page_len, filters): product_bundles = frappe.db.get_list("Product Bundle", {"disabled": 0}, pluck="name") + item = frappe.qb.DocType("Item") - return ( + query = ( frappe.qb.from_(item) .select("*") .where( - (item.is_stock_item == 0) - & (item.is_fixed_asset == 0) - & (item.name.notin(product_bundles)) - & (item[searchfield].like(f"%{txt}%")) + (item.is_stock_item == 0) & (item.is_fixed_asset == 0) & (item[searchfield].like(f"%{txt}%")) ) .limit(page_len) .offset(start) - ).run() + ) + + if product_bundles: + query = query.where(item.name.notin(product_bundles)) + + return query.run() From 8c3713b649c7777e35be74b7afe437cec682359e Mon Sep 17 00:00:00 2001 From: s-aga-r Date: Tue, 28 Nov 2023 11:12:55 +0530 Subject: [PATCH 2/2] fix: don't select all fields --- erpnext/selling/doctype/product_bundle/product_bundle.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/selling/doctype/product_bundle/product_bundle.py b/erpnext/selling/doctype/product_bundle/product_bundle.py index c934f0dffa5d..3d4ffebbfb43 100644 --- a/erpnext/selling/doctype/product_bundle/product_bundle.py +++ b/erpnext/selling/doctype/product_bundle/product_bundle.py @@ -80,7 +80,7 @@ def get_new_item_code(doctype, txt, searchfield, start, page_len, filters): item = frappe.qb.DocType("Item") query = ( frappe.qb.from_(item) - .select("*") + .select(item.item_code, item.item_name) .where( (item.is_stock_item == 0) & (item.is_fixed_asset == 0) & (item[searchfield].like(f"%{txt}%")) )