mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-12 06:01:46 +00:00
fix: typeerror in get_batches_by_oldest for mixed batch expiry
sort on (expiry is none, expiry) so a null expiry_date is never
order-compared against a datetime.date, which raised typeerror in
python 3 when a warehouse held both dated and never-expiring batches.
(cherry picked from commit 62c9f8ee3e)
This commit is contained in:
@@ -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"""
|
"""Returns the oldest batch and qty for the given item_code and warehouse"""
|
||||||
batches = get_batch_qty(item_code=item_code, warehouse=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 = [[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
|
return batches_dates
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user