get_query to server side

This commit is contained in:
Saurabh
2013-07-10 17:35:14 +05:30
parent a29b69245e
commit ee85cfd476
13 changed files with 116 additions and 83 deletions

View File

@@ -177,7 +177,9 @@ def item_details(doctype, txt, searchfield, start, page_len, filters):
from controllers.queries import get_match_cond
return webnotes.conn.sql("""select name, item_name, description from `tabItem`
where name in ( select item_code FROM `tabDelivery Note Item`
where parent= %s and ifnull(qty, 0) > ifnull(packed_qty, 0))
and %s like "%s" %s limit %s, %s """ % ("%s", searchfield, "%s",
where parent= %s
and ifnull(qty, 0) > ifnull(packed_qty, 0))
and %s like "%s" %s
limit %s, %s """ % ("%s", searchfield, "%s",
get_match_cond(doctype, searchfield), "%s", "%s"),
(filters["delivery_note"], "%%%s%%" % txt, start, page_len))

View File

@@ -717,7 +717,8 @@ def query_sales_return_doc(doctype, txt, searchfield, start, page_len, filters):
return webnotes.conn.sql("""select name, customer, customer_name
from `tab%s` where docstatus = 1
and (`%s` like %%(txt)s or `customer` like %%(txt)s) %s %s
and (`%s` like %%(txt)s
or `customer` like %%(txt)s) %s %s
order by name, customer, customer_name
limit %s""" % (doctype, searchfield, conditions,
get_match_cond(doctype, searchfield), "%(start)s, %(page_len)s"),
@@ -728,7 +729,8 @@ def query_purchase_return_doc(doctype, txt, searchfield, start, page_len, filter
from controllers.queries import get_match_cond
return webnotes.conn.sql("""select name, supplier, supplier_name
from `tab%s` where docstatus = 1
and (`%s` like %%(txt)s or `supplier` like %%(txt)s) %s
and (`%s` like %%(txt)s
or `supplier` like %%(txt)s) %s
order by name, supplier, supplier_name
limit %s""" % (doctype, searchfield, get_match_cond(doctype, searchfield),
"%(start)s, %(page_len)s"), {"txt": "%%%s%%" % txt, "start":
@@ -762,15 +764,21 @@ def get_batch_no(doctype, txt, searchfield, start, page_len, filters):
from controllers.queries import get_match_cond
return webnotes.conn.sql("""select batch_no from `tabStock Ledger Entry` sle
where item_code = '%(item_code)s' and warehouse = '%(s_warehouse)s'
and ifnull(is_cancelled, 'No') = 'No' and batch_no like '%(txt)s'
and exists(select * from `tabBatch` where name = sle.batch_no
and expiry_date >= %(posting_date)s and docstatus != 2) %(mcond)s
group by batch_no having sum(actual_qty) > 0
order by batch_no desc limit %(start)s, %(page_len)s """
% {'item_code': filters['item_code'], 's_warehouse': filters['s_warehouse'],
'posting_date': filters['posting_date'], 'txt': "%%%s%%" % txt,
'mcond':get_match_cond(doctype, searchfield),"start": start, "page_len": page_len})
where item_code = '%(item_code)s'
and warehouse = '%(s_warehouse)s'
and ifnull(is_cancelled, 'No') = 'No'
and batch_no like '%(txt)s'
and exists(select * from `tabBatch`
where name = sle.batch_no
and expiry_date >= %(posting_date)s
and docstatus != 2)
%(mcond)s
group by batch_no having sum(actual_qty) > 0
order by batch_no desc
limit %(start)s, %(page_len)s """ % {'item_code': filters['item_code'],
's_warehouse': filters['s_warehouse'], 'posting_date': filters['posting_date'],
'txt': "%%%s%%" % txt, 'mcond':get_match_cond(doctype, searchfield),
"start": start, "page_len": page_len})
def get_stock_items_for_return(ref_doclist, parentfields):
"""return item codes filtered from doclist, which are stock items"""