Merge pull request #44053 from aerele/pos_barcode_search_fix

Pos barcode search fix
This commit is contained in:
ruthra kumar
2024-11-12 12:44:32 +05:30
committed by GitHub
2 changed files with 9 additions and 1 deletions

View File

@@ -35,6 +35,7 @@ def search_by_term(search_term, warehouse, price_list):
"description": item_doc.description,
"is_stock_item": item_doc.is_stock_item,
"item_code": item_doc.name,
"item_group": item_doc.item_group,
"item_image": item_doc.image,
"item_name": item_doc.item_name,
"serial_no": serial_no,
@@ -92,6 +93,12 @@ def search_by_term(search_term, warehouse, price_list):
return {"items": [item]}
def filter_result_items(result, pos_profile):
if result and result.get("items"):
pos_item_groups = frappe.db.get_all("POS Item Group", {"parent": pos_profile}, pluck="item_group")
result["items"] = [item for item in result.get("items") if item.get("item_group") in pos_item_groups]
@frappe.whitelist()
def get_items(start, page_length, price_list, item_group, pos_profile, search_term=""):
warehouse, hide_unavailable_items = frappe.db.get_value(
@@ -102,6 +109,7 @@ def get_items(start, page_length, price_list, item_group, pos_profile, search_te
if search_term:
result = search_by_term(search_term, warehouse, price_list) or []
filter_result_items(result, pos_profile)
if result:
return result

View File

@@ -138,7 +138,6 @@ erpnext.PointOfSale.ItemSelector = class {
make_search_bar() {
const me = this;
const doc = me.events.get_frm().doc;
this.$component.find(".search-field").html("");
this.$component.find(".item-group-field").html("");
@@ -163,6 +162,7 @@ erpnext.PointOfSale.ItemSelector = class {
me.filter_items();
},
get_query: function () {
const doc = me.events.get_frm().doc;
return {
query: "erpnext.selling.page.point_of_sale.point_of_sale.item_group_query",
filters: {