Merge pull request #57414 from frappe/mergify/bp/version-15-hotfix/pr-57413

fix: typeerror in get_batches_by_oldest for mixed batch expiry (backport #57413)
This commit is contained in:
Mihir Kandoi
2026-07-23 18:46:43 +05:30
committed by GitHub

View File

@@ -298,7 +298,7 @@ def get_batches_by_oldest(item_code, warehouse):
"""Returns the oldest batch and qty for the given item_code and warehouse"""
batches = get_batch_qty(item_code=item_code, warehouse=warehouse)
batches_dates = [[batch, frappe.get_value("Batch", batch.batch_no, "expiry_date")] for batch in batches]
batches_dates.sort(key=lambda tup: tup[1])
batches_dates.sort(key=lambda tup: (tup[1] is None, tup[1]))
return batches_dates