get_query to servet side

This commit is contained in:
Saurabh
2013-07-10 16:06:31 +05:30
parent 2deca5f3f6
commit a29b69245e
2 changed files with 93 additions and 49 deletions

View File

@@ -141,17 +141,27 @@ class DocType:
msgprint("No amount allocated.", raise_exception=1)
def gl_entry_details(doctype, txt, searchfield, start, page_len, filters):
("""select gle.voucher_no, gle.posting_date, gle.%(account_type)s
from `tabGL Entry` gle
where gle.account = '%(acc)s' and gle.voucher_type = '%(dt)s'
and gle.voucher_no like '%s' and ifnull(gle.is_cancelled, 'No') = 'No'
and (ifnull(gle.against_voucher, '') = '' or ifnull(gle.against_voucher, '') = gle.voucher_no )
and ifnull(gle.%(account_type)s, 0) > 0
and (select ifnull(abs(sum(ifnull(debit, 0)) - sum(ifnull(credit, 0))), 0)
from `tabGL Entry`
where against_voucher_type = '%(dt)s' and against_voucher = gle.voucher_no
and voucher_no != gle.voucher_no
and ifnull(is_cancelled, 'No') = 'No') != abs(ifnull(gle.debit, 0) - ifnull(gle.credit, 0))
ORDER BY gle.posting_date DESC, gle.voucher_no DESC limit %(start)s, %(page_len)s"""%
{dt:filters["dt"], acc:filters["acc"], account_type: filters['account_type'], "start": start,
"page_len": page_len})
from controllers.queries import get_match_cond
return webnotes.conn.sql("""select gle.voucher_no, gle.posting_date,
gle.%(account_type)s from `tabGL Entry` gle
where gle.account = '%(acc)s'
and gle.voucher_type = '%(dt)s'
and gle.voucher_no like '%(txt)s'
and ifnull(gle.is_cancelled, 'No') = 'No'
and (ifnull(gle.against_voucher, '') = ''
or ifnull(gle.against_voucher, '') = gle.voucher_no )
and ifnull(gle.%(account_type)s, 0) > 0
and (select ifnull(abs(sum(ifnull(debit, 0))
- sum(ifnull(credit, 0))), 0)
from `tabGL Entry`
where against_voucher_type = '%(dt)s'
and against_voucher = gle.voucher_no
and voucher_no != gle.voucher_no
and ifnull(is_cancelled, 'No') = 'No')
!= abs(ifnull(gle.debit, 0) - ifnull(gle.credit, 0))
%(mcond)s
ORDER BY gle.posting_date desc, gle.voucher_no desc
limit %(start)s, %(page_len)s""" % {dt:filters["dt"], acc:filters["acc"],
account_type: filters['account_type'], 'mcond':get_match_cond(doctype, searchfield)
'txt': "%%%s%%" % txt,"start": start, "page_len": page_len})