Pick batch autmatically only if batch found

This commit is contained in:
Nabin Hait 2017-04-26 14:29:33 +05:30
parent db8f41ba55
commit 96c247c834

View File

@ -101,11 +101,13 @@ def set_batch_nos(doc, warehouse_field, throw = False):
def get_batch_no(item_code, warehouse, qty, throw=False): def get_batch_no(item_code, warehouse, qty, throw=False):
'''get the smallest batch with for the given item_code, warehouse and qty''' '''get the smallest batch with for the given item_code, warehouse and qty'''
batches = sorted(
get_batch_qty(item_code = item_code, warehouse = warehouse),
lambda a, b: 1 if a.qty > b.qty else -1)
batch_no = None batch_no = None
batches = get_batch_qty(item_code = item_code, warehouse = warehouse)
if batches:
batches = sorted(batches, lambda a, b: 1 if a.qty > b.qty else -1)
for b in batches: for b in batches:
if b.qty >= qty: if b.qty >= qty:
batch_no = b.batch_no batch_no = b.batch_no