fix: ambihious error (#20068)

This commit is contained in:
Himanshu 2019-12-24 12:31:38 +05:30 committed by Nabin Hait
parent 088be37e64
commit 5af4c57ef7

View File

@ -261,15 +261,14 @@ def get_batch_no(item_code, warehouse, qty=1, throw=False):
def get_batches(item_code, warehouse, qty=1, throw=False):
batches = frappe.db.sql(
'select batch_id, sum(actual_qty) as qty from `tabBatch` join `tabStock Ledger Entry` ignore index (item_code, warehouse) '
'on (`tabBatch`.batch_id = `tabStock Ledger Entry`.batch_no )'
'where `tabStock Ledger Entry`.item_code = %s and `tabStock Ledger Entry`.warehouse = %s '
'and (`tabBatch`.expiry_date >= CURDATE() or `tabBatch`.expiry_date IS NULL)'
'group by batch_id '
'order by `tabBatch`.expiry_date ASC, `tabBatch`.creation ASC',
(item_code, warehouse),
as_dict=True
)
return batches
return frappe.db.sql("""
select batch_id, sum(`tabStock Ledger Entry`.actual_qty) as qty
from `tabBatch`
join `tabStock Ledger Entry` ignore index (item_code, warehouse)
on (`tabBatch`.batch_id = `tabStock Ledger Entry`.batch_no )
where `tabStock Ledger Entry`.item_code = %s and `tabStock Ledger Entry`.warehouse = %s
and (`tabBatch`.expiry_date >= CURDATE() or `tabBatch`.expiry_date IS NULL)
group by batch_id
order by `tabBatch`.expiry_date ASC, `tabBatch`.creation ASC'
""", (item_code, warehouse), as_dict=True)