get_query shifted to server for account
diff --git a/accounts/doctype/account/account.js b/accounts/doctype/account/account.js
index 14e35d3..7738682 100644
--- a/accounts/doctype/account/account.js
+++ b/accounts/doctype/account/account.js
@@ -116,19 +116,18 @@
   });
 }
 
-// Master name get query
-// -----------------------------------------
-cur_frm.fields_dict['master_name'].get_query=function(doc){
- if (doc.master_type){
-    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';
-  }
+cur_frm.fields_dict['master_name'].get_query = function(doc) {
+	if (doc.master_type) {
+		return {
+			query: "accounts.doctype.account.account.get_master_name",
+			args: {	"master_type": doc.master_type }
+		}
+	}
 }
 
-// parent account get query
-// -----------------------------------------
-cur_frm.fields_dict['parent_account'].get_query = function(doc){
-  return 'SELECT DISTINCT `tabAccount`.name FROM `tabAccount` WHERE \
-	`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';
+cur_frm.fields_dict['parent_account'].get_query = function(doc) {
+	return {
+		query: "accounts.doctype.account.account.get_parent_account",
+		args: { "company": doc.company}
+	}
 }
diff --git a/accounts/doctype/account/account.py b/accounts/doctype/account/account.py
index 04e13d8..57ab191 100644
--- a/accounts/doctype/account/account.py
+++ b/accounts/doctype/account/account.py
@@ -200,4 +200,13 @@
 		sql("update `tabAccount` set account_name = '%s' where name = '%s'" % \
 			(account_name, old))
 
-		return " - ".join(parts)
\ No newline at end of file
+		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))
\ No newline at end of file
diff --git a/stock/utils.py b/stock/utils.py
index 87f4c02..3b98cf0 100644
--- a/stock/utils.py
+++ b/stock/utils.py
@@ -148,7 +148,7 @@
 		
 	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"""
 	wlist = []
 	for w in webnotes.conn.sql_list("""select name from tabWarehouse