mirror of
https://github.com/frappe/erpnext.git
synced 2026-02-16 16:15:02 +00:00
Merge pull request #44053 from aerele/pos_barcode_search_fix
Pos barcode search fix
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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: {
|
||||
|
||||
Reference in New Issue
Block a user