From fe5c458c4525915939369466bac222aa6b9bbd54 Mon Sep 17 00:00:00 2001 From: Diptanil Saha Date: Mon, 13 Jan 2025 12:06:46 +0530 Subject: [PATCH] fix: batch number search on pos (#45209) * fix: price of items with batch number not having seperate item price on pos search bar * fix: introduced batch number based sorting (cherry picked from commit e529f82392a92ae927d326ca3ab1fc7a08eb7924) --- .../page/point_of_sale/point_of_sale.py | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/erpnext/selling/page/point_of_sale/point_of_sale.py b/erpnext/selling/page/point_of_sale/point_of_sale.py index f00b7d0fc55..b86a87983d5 100644 --- a/erpnext/selling/page/point_of_sale/point_of_sale.py +++ b/erpnext/selling/page/point_of_sale/point_of_sale.py @@ -64,7 +64,7 @@ def search_by_term(search_term, warehouse, price_list): } if batch_no: - price_filters["batch_no"] = batch_no + price_filters["batch_no"] = ["in", [batch_no, ""]] price = frappe.get_list( doctype="Item Price", @@ -74,15 +74,25 @@ def search_by_term(search_term, warehouse, price_list): def __sort(p): p_uom = p.get("uom") + p_batch = p.get("batch_no") + batch_no = item.get("batch_no") + + if batch_no and p_batch and p_batch == batch_no: + if p_uom == item.get("uom"): + return 0 + elif p_uom == item.get("stock_uom"): + return 1 + else: + return 2 if p_uom == item.get("uom"): - return 0 + return 3 elif p_uom == item.get("stock_uom"): - return 1 + return 4 else: - return 2 + return 5 - # sort by fallback preference. always pick exact uom match if available + # sort by fallback preference. always pick exact uom and batch number match if available price = sorted(price, key=__sort) if len(price) > 0: