fix: Rate for items with no batch
diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py
index a5f8e5f..2d2abd7 100644
--- a/erpnext/stock/get_item_details.py
+++ b/erpnext/stock/get_item_details.py
@@ -672,6 +672,8 @@
and price_list=%(price_list)s
and ifnull(uom, '') in ('', %(uom)s)"""
+ conditions += "and ifnull(batch_no, '') in ('', %(batch_no)s)"
+
if not ignore_party:
if args.get("customer"):
conditions += " and customer=%(customer)s"
@@ -680,9 +682,6 @@
else:
conditions += "and (customer is null or customer = '') and (supplier is null or supplier = '')"
- if args.get('batch_no'):
- conditions += "and batch_no = %(batch_no)s"
-
if args.get('transaction_date'):
conditions += """ and %(transaction_date)s between
ifnull(valid_from, '2000-01-01') and ifnull(valid_upto, '2500-12-31')"""
@@ -693,7 +692,7 @@
return frappe.db.sql(""" select name, price_list_rate, uom
from `tabItem Price` {conditions}
- order by valid_from desc, uom desc """.format(conditions=conditions), args)
+ order by valid_from desc, batch_no desc, uom desc """.format(conditions=conditions), args)
def get_price_list_rate_for(args, item_code):
"""