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 e529f82392)
This commit is contained in:
@@ -64,7 +64,7 @@ def search_by_term(search_term, warehouse, price_list):
|
|||||||
}
|
}
|
||||||
|
|
||||||
if batch_no:
|
if batch_no:
|
||||||
price_filters["batch_no"] = batch_no
|
price_filters["batch_no"] = ["in", [batch_no, ""]]
|
||||||
|
|
||||||
price = frappe.get_list(
|
price = frappe.get_list(
|
||||||
doctype="Item Price",
|
doctype="Item Price",
|
||||||
@@ -74,15 +74,25 @@ def search_by_term(search_term, warehouse, price_list):
|
|||||||
|
|
||||||
def __sort(p):
|
def __sort(p):
|
||||||
p_uom = p.get("uom")
|
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"):
|
if p_uom == item.get("uom"):
|
||||||
return 0
|
return 3
|
||||||
elif p_uom == item.get("stock_uom"):
|
elif p_uom == item.get("stock_uom"):
|
||||||
return 1
|
return 4
|
||||||
else:
|
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)
|
price = sorted(price, key=__sort)
|
||||||
|
|
||||||
if len(price) > 0:
|
if len(price) > 0:
|
||||||
|
|||||||
Reference in New Issue
Block a user