Merge pull request #45234 from frappe/mergify/bp/version-15-hotfix/pr-45209

fix: batch number search on pos (backport #45209)
This commit is contained in:
ruthra kumar
2025-01-14 11:42:04 +05:30
committed by GitHub

View File

@@ -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: