match condition in get_query

This commit is contained in:
Nabin Hait 2015-03-20 14:40:36 +05:30
parent 7b4b31fdf7
commit 5601d9fbda

View File

@ -696,16 +696,15 @@ def get_batch_no(doctype, txt, searchfield, start, page_len, filters):
} }
if filters.get("s_warehouse"): if filters.get("s_warehouse"):
batch_nos = frappe.db.sql("""select batch_no batch_nos = frappe.db.sql("""select sle.batch_no
from `tabStock Ledger Entry` sle from `tabStock Ledger Entry` sle, `tabBatch`
where item_code = '%(item_code)s' where sle.batch_no = `tabBatch`.name
and warehouse = '%(s_warehouse)s' and sle.item_code = '%(item_code)s'
and batch_no like '%(txt)s' and sle.warehouse = '%(s_warehouse)s'
and exists(select * from `tabBatch` and sle.batch_no like '%(txt)s'
where name = sle.batch_no and (ifnull(`tabBatch`.expiry_date, '2099-12-31') >= %(posting_date)s
and (ifnull(expiry_date, '2099-12-31') >= %(posting_date)s or `tabBatch`.expiry_date = '')
or expiry_date = '') and `tabBatch`.docstatus != 2
and docstatus != 2)
%(mcond)s %(mcond)s
group by batch_no having sum(actual_qty) > 0 group by batch_no having sum(actual_qty) > 0
order by batch_no desc order by batch_no desc