get_query shifted to server for account

This commit is contained in:
Nabin Hait 2013-02-06 17:40:14 +05:30
parent c7ac4cbda4
commit fa230e47f4
3 changed files with 23 additions and 15 deletions

View File

@ -116,19 +116,18 @@ cur_frm.cscript.convert_to_group = function(doc, cdt, cdn) {
}); });
} }
// Master name get query cur_frm.fields_dict['master_name'].get_query = function(doc) {
// ----------------------------------------- if (doc.master_type) {
cur_frm.fields_dict['master_name'].get_query=function(doc){ return {
if (doc.master_type){ query: "accounts.doctype.account.account.get_master_name",
return 'SELECT `tab'+doc.master_type+'`.name FROM `tab'+doc.master_type+'` WHERE `tab'+doc.master_type+'`.name LIKE "%s" and `tab'+doc.master_type+'`.docstatus != 2 ORDER BY `tab'+doc.master_type+'`.name LIMIT 50'; args: { "master_type": doc.master_type }
} }
}
} }
// parent account get query cur_frm.fields_dict['parent_account'].get_query = function(doc) {
// ----------------------------------------- return {
cur_frm.fields_dict['parent_account'].get_query = function(doc){ query: "accounts.doctype.account.account.get_parent_account",
return 'SELECT DISTINCT `tabAccount`.name FROM `tabAccount` WHERE \ args: { "company": doc.company}
`tabAccount`.group_or_ledger="Group" AND `tabAccount`.docstatus != 2 AND \ }
`tabAccount`.company="'+ doc.company+'" AND `tabAccount`.company is not NULL AND \
`tabAccount`.name LIKE "%s" ORDER BY `tabAccount`.name LIMIT 50';
} }

View File

@ -200,4 +200,13 @@ class DocType:
sql("update `tabAccount` set account_name = '%s' where name = '%s'" % \ sql("update `tabAccount` set account_name = '%s' where name = '%s'" % \
(account_name, old)) (account_name, old))
return " - ".join(parts) return " - ".join(parts)
def get_master_name(doctype, txt, searchfield, start, page_len, args):
return webnotes.conn.sql("""select name from `tab%s` where name like '%%%s%%'""" %
(args["master_type"], txt), as_list=1)
def get_parent_account(doctype, txt, searchfield, start, page_len, args):
return webnotes.conn.sql("""select name from tabAccount
where group_or_ledger = 'Group' and docstatus != 2 and company = '%s'
and name like '%%%s%%'""" % (args["company"], txt))

View File

@ -148,7 +148,7 @@ def get_valid_serial_nos(sr_nos, qty=0, item_code=''):
return valid_serial_nos return valid_serial_nos
def get_warehouse_list(doctype, txt, searchfield, start, page_len): def get_warehouse_list(doctype, txt, searchfield, start, page_len, args):
"""used in search queries""" """used in search queries"""
wlist = [] wlist = []
for w in webnotes.conn.sql_list("""select name from tabWarehouse for w in webnotes.conn.sql_list("""select name from tabWarehouse