mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-02 03:39:11 +00:00
[get_query]to server side
This commit is contained in:
@@ -45,8 +45,7 @@ cur_frm.fields_dict['budget_details'].grid.get_field('account').get_query = func
|
||||
['Account', 'group_or_ledger', 'is not', 'NULL']
|
||||
]
|
||||
}
|
||||
// return 'SELECT DISTINCT `tabAccount`.`name`,`tabAccount`.debit_or_credit,`tabAccount`.group_or_ledger FROM `tabAccount` WHERE `tabAccount`.`company` = "' + doc.company_name + '" AND `tabAccount`.docstatus != 2 AND `tabAccount`.`is_pl_account` = "Yes" AND `tabAccount`.debit_or_credit = "Debit" AND `tabAccount`.`group_or_ledger` != "Group" AND `tabAccount`.`group_or_ledger` is not NULL AND `tabAccount`.`name` LIKE "%s" ORDER BY `tabAccount`.`name` LIMIT 50';
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['parent_cost_center'].get_query = function(doc){
|
||||
return{
|
||||
@@ -56,7 +55,6 @@ cur_frm.fields_dict['parent_cost_center'].get_query = function(doc){
|
||||
['Cost Center', 'company_name', 'is not', 'NULL']
|
||||
]
|
||||
}
|
||||
// return 'SELECT DISTINCT `tabCost Center`.name FROM `tabCost Center` WHERE `tabCost Center`.group_or_ledger="Group" AND `tabCost Center`.docstatus != 2 AND `tabCost Center`.company_name="'+ doc.company_name+'" AND `tabCost Center`.company_name is not NULL AND `tabCost Center`.name LIKE "%s" ORDER BY `tabCost Center`.name LIMIT 50';
|
||||
}
|
||||
|
||||
//parent cost center
|
||||
|
||||
@@ -196,7 +196,6 @@ cur_frm.fields_dict['entries'].grid.get_field('account').get_query = function(do
|
||||
|
||||
cur_frm.fields_dict["entries"].grid.get_field("cost_center").get_query = function(doc) {
|
||||
return {
|
||||
// query: "accounts.utils.get_cost_center_list",
|
||||
filters: {
|
||||
'company_name': doc.company,
|
||||
'group_or_ledger': 'Ledger'
|
||||
@@ -207,7 +206,6 @@ cur_frm.fields_dict["entries"].grid.get_field("cost_center").get_query = functio
|
||||
cur_frm.fields_dict['entries'].grid.get_field('against_voucher').get_query = function(doc) {
|
||||
var d = locals[this.doctype][this.docname];
|
||||
return {
|
||||
// query: "accounts.doctype.journal_voucher.journal_voucher.get_against_purchase_invoice",
|
||||
filters: [
|
||||
['Purchase Invoice', 'credit_to', '=', d.account],
|
||||
['Purchase Invoice', 'docstatus', '=', 1],
|
||||
@@ -219,7 +217,6 @@ cur_frm.fields_dict['entries'].grid.get_field('against_voucher').get_query = fun
|
||||
cur_frm.fields_dict['entries'].grid.get_field('against_invoice').get_query = function(doc) {
|
||||
var d = locals[this.doctype][this.docname];
|
||||
return {
|
||||
// query: "accounts.doctype.journal_voucher.journal_voucher.get_against_sales_invoice",
|
||||
filters: [
|
||||
['Sales Invoice', 'debit_to', '=', d.account],
|
||||
['Sales Invoice', 'docstatus', '=', 1],
|
||||
|
||||
@@ -32,5 +32,4 @@ cur_frm.fields_dict['closing_account_head'].get_query = function(doc, cdt, cdn)
|
||||
"group_or_ledger": "Ledger"
|
||||
}
|
||||
}
|
||||
// return 'SELECT `tabAccount`.name FROM `tabAccount` WHERE `tabAccount`.is_pl_account = "No" AND `tabAccount`.debit_or_credit = "Credit" AND `tabAccount`.company = "'+ cstr(doc.company) +'" AND ifnull(`tabAccount`.freeze_account, "No") = "No" AND `tabAccount`.group_or_ledger = "Ledger" AND `tabAccount`.%(key)s LIKE "%s" ORDER BY `tabAccount`.name ASC LIMIT 50';
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@ cur_frm.fields_dict['cash_bank_account'].get_query = function(doc,cdt,cdn) {
|
||||
'company': doc.company
|
||||
}
|
||||
}
|
||||
// return 'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.debit_or_credit="Debit" AND tabAccount.is_pl_account = "No" AND tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus!=2 AND tabAccount.company="'+doc.company+'" AND tabAccount.%(key)s LIKE "%s"'
|
||||
}
|
||||
|
||||
// Income Account
|
||||
@@ -47,7 +46,6 @@ cur_frm.fields_dict['income_account'].get_query = function(doc,cdt,cdn) {
|
||||
'account_type': "Income Account"
|
||||
}
|
||||
}
|
||||
// return 'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.debit_or_credit="Credit" AND tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus!=2 AND tabAccount.company="'+doc.company+'" AND tabAccount.account_type ="Income Account" AND tabAccount.%(key)s LIKE "%s"'
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +58,6 @@ cur_frm.fields_dict['cost_center'].get_query = function(doc,cdt,cdn) {
|
||||
'group_or_ledger': "Ledger",
|
||||
}
|
||||
}
|
||||
// return 'SELECT `tabCost Center`.`name` FROM `tabCost Center` WHERE `tabCost Center`.`company_name` = "' +doc.company+'" AND `tabCost Center`.%(key)s LIKE "%s" AND `tabCost Center`.`group_or_ledger` = "Ledger" AND `tabCost Center`.`docstatus`!= 2 ORDER BY `tabCost Center`.`name` ASC LIMIT 50';
|
||||
}
|
||||
|
||||
//get query select Territory
|
||||
@@ -71,7 +68,6 @@ cur_frm.fields_dict['territory'].get_query = function(doc,cdt,cdn) {
|
||||
'is_group': "No"
|
||||
}
|
||||
}
|
||||
// return 'SELECT `tabTerritory`.`name`,`tabTerritory`.`parent_territory` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "No" AND `tabTerritory`.`docstatus`!= 2 AND `tabTerritory`.%(key)s LIKE "%s" ORDER BY `tabTerritory`.`name` ASC LIMIT 50';
|
||||
}
|
||||
|
||||
|
||||
@@ -82,12 +78,10 @@ cur_frm.fields_dict['select_print_heading'].get_query = function(doc, cdt, cdn)
|
||||
['Print Heading', 'docstatus', '!=', 2]
|
||||
]
|
||||
}
|
||||
// return 'SELECT `tabPrint Heading`.name FROM `tabPrint Heading` WHERE `tabPrint Heading`.docstatus !=2 AND `tabPrint Heading`.name LIKE "%s" ORDER BY `tabPrint Heading`.name ASC LIMIT 50';
|
||||
}
|
||||
|
||||
cur_frm.fields_dict["expense_account"].get_query = function(doc) {
|
||||
return {
|
||||
// "query": "accounts.utils.get_account_list",
|
||||
filters: {
|
||||
"is_pl_account": "Yes",
|
||||
"debit_or_credit": "Debit",
|
||||
|
||||
@@ -155,14 +155,12 @@ cur_frm.fields_dict['supplier_address'].get_query = function(doc, cdt, cdn) {
|
||||
return{
|
||||
filters:{'supplier': doc.supplier}
|
||||
}
|
||||
// return 'SELECT name,address_line1,city FROM tabAddress WHERE supplier = "'+ doc.supplier +'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['contact_person'].get_query = function(doc, cdt, cdn) {
|
||||
return{
|
||||
filters:{'supplier': doc.supplier}
|
||||
}
|
||||
// return 'SELECT name,CONCAT(first_name," ",ifnull(last_name,"")) As FullName,department,designation FROM tabContact WHERE supplier = "'+ doc.supplier +'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['entries'].grid.get_field("item_code").get_query = function(doc, cdt, cdn) {
|
||||
@@ -183,43 +181,6 @@ cur_frm.fields_dict['credit_to'].get_query = function(doc) {
|
||||
'company': doc.company
|
||||
}
|
||||
}
|
||||
// return 'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.debit_or_credit="Credit" AND tabAccount.is_pl_account="No" AND tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus != 2 AND tabAccount.company="'+doc.company+'" AND tabAccount.%(key)s LIKE "%s"'
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['purchase_order_main'].get_query = function(doc) {
|
||||
var filter = [
|
||||
['Purchase Order', 'docstatus', '=', 1],
|
||||
['Purchase Order', 'status', '!=', 'Stopped'],
|
||||
['Purchase Order', 'per_billed', '<', 99.99],
|
||||
['Purchase Order', 'company', '=', doc.company]
|
||||
];
|
||||
var cond = [];
|
||||
if (doc.supplier){
|
||||
cond = ['Purchase Order', 'supplier', '=', doc.supplier];
|
||||
// return 'SELECT `tabPurchase Order`.`name` FROM `tabPurchase Order` WHERE `tabPurchase Order`.`docstatus` = 1 AND `tabPurchase Order`.supplier = "'+ doc.supplier +'" AND `tabPurchase Order`.`status` != "Stopped" AND ifnull(`tabPurchase Order`.`per_billed`,0) < 99.99 AND `tabPurchase Order`.`company` = "' + doc.company + '" AND `tabPurchase Order`.%(key)s LIKE "%s" ORDER BY `tabPurchase Order`.`name` DESC LIMIT 50'
|
||||
}
|
||||
filter.push(cond);
|
||||
return{
|
||||
filters: filter
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['purchase_receipt_main'].get_query = function(doc) {
|
||||
var filter = [
|
||||
['Purchase Receipt', 'docstatus', '=', 1],
|
||||
['Purchase Receipt', 'status', '!=', 'Stopped'],
|
||||
['Purchase Receipt', 'per_billed', '<', 99.99],
|
||||
['Purchase Receipt', 'company', '=', doc.company]
|
||||
];
|
||||
var cond = [];
|
||||
if (doc.supplier){
|
||||
['Purchase Receipt', 'supplier', '=', doc.supplier];
|
||||
// return 'SELECT `tabPurchase Receipt`.`name` FROM `tabPurchase Receipt` WHERE `tabPurchase Receipt`.`docstatus` = 1 AND `tabPurchase Receipt`.supplier = "'+ doc.supplier +'" AND `tabPurchase Receipt`.`status` != "Stopped" AND ifnull(`tabPurchase Receipt`.`per_billed`, 0) < 99.99 AND `tabPurchase Receipt`.`company` = "' + doc.company + '" AND `tabPurchase Receipt`.%(key)s LIKE "%s" ORDER BY `tabPurchase Receipt`.`name` DESC LIMIT 50'
|
||||
}
|
||||
filter.push(cond);
|
||||
return{
|
||||
filters: filter
|
||||
}
|
||||
}
|
||||
|
||||
// Get Print Heading
|
||||
@@ -229,7 +190,6 @@ return{
|
||||
['Print Heading', 'docstatus', '!=', 2]
|
||||
]
|
||||
}
|
||||
// return 'SELECT `tabPrint Heading`.name FROM `tabPrint Heading` WHERE `tabPrint Heading`.docstatus !=2 AND `tabPrint Heading`.name LIKE "%s" ORDER BY `tabPrint Heading`.name ASC LIMIT 50';
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['entries'].grid.get_field("expense_head").get_query = function(doc) {
|
||||
@@ -241,7 +201,6 @@ cur_frm.fields_dict['entries'].grid.get_field("expense_head").get_query = functi
|
||||
'company': doc.company
|
||||
}
|
||||
}
|
||||
// return 'SELECT tabAccount.name FROM tabAccount WHERE (tabAccount.debit_or_credit="Debit" OR tabAccount.account_type = "Expense Account") AND tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus != 2 AND tabAccount.company="'+doc.company+'" AND tabAccount.%(key)s LIKE "%s"';
|
||||
}
|
||||
cur_frm.cscript.expense_head = function(doc, cdt, cdn){
|
||||
var d = locals[cdt][cdn];
|
||||
@@ -256,7 +215,6 @@ cur_frm.cscript.expense_head = function(doc, cdt, cdn){
|
||||
|
||||
cur_frm.fields_dict["entries"].grid.get_field("cost_center").get_query = function(doc) {
|
||||
return {
|
||||
// query: "accounts.utils.get_cost_center_list",
|
||||
filters: {
|
||||
'company_name': doc.company,
|
||||
'group_or_ledger': 'Ledger'
|
||||
@@ -307,9 +265,6 @@ cur_frm.fields_dict['entries'].grid.get_field('project_name').get_query = functi
|
||||
['Project', 'status', 'not in', 'Completed, Cancelled']
|
||||
]
|
||||
}
|
||||
// return 'SELECT `tabProject`.name FROM `tabProject` \
|
||||
// WHERE `tabProject`.status not in ("Completed", "Cancelled") \
|
||||
// AND `tabProject`.name LIKE "%s" ORDER BY `tabProject`.name ASC LIMIT 50';
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -257,7 +257,6 @@ cur_frm.fields_dict.debit_to.get_query = function(doc) {
|
||||
'company': doc.company
|
||||
}
|
||||
}
|
||||
// return 'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.debit_or_credit="Debit" AND tabAccount.is_pl_account = "No" AND tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus!=2 AND tabAccount.company="'+doc.company+'" AND tabAccount.%(key)s LIKE "%s"'
|
||||
}
|
||||
|
||||
cur_frm.fields_dict.cash_bank_account.get_query = function(doc) {
|
||||
@@ -269,7 +268,6 @@ cur_frm.fields_dict.cash_bank_account.get_query = function(doc) {
|
||||
'company': doc.company
|
||||
}
|
||||
}
|
||||
// return 'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.debit_or_credit="Debit" AND tabAccount.is_pl_account = "No" AND tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus!=2 AND tabAccount.company="'+doc.company+'" AND tabAccount.%(key)s LIKE "%s"'
|
||||
}
|
||||
|
||||
cur_frm.fields_dict.write_off_account.get_query = function(doc) {
|
||||
@@ -281,7 +279,6 @@ cur_frm.fields_dict.write_off_account.get_query = function(doc) {
|
||||
'company': doc.company
|
||||
}
|
||||
}
|
||||
// return 'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.debit_or_credit="Debit" AND tabAccount.is_pl_account = "Yes" AND tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus!=2 AND tabAccount.company="'+doc.company+'" AND tabAccount.%(key)s LIKE "%s"'
|
||||
}
|
||||
|
||||
// Write off cost center
|
||||
@@ -294,7 +291,6 @@ cur_frm.fields_dict.write_off_cost_center.get_query = function(doc) {
|
||||
'company_name': doc.company
|
||||
}
|
||||
}
|
||||
// return 'SELECT `tabCost Center`.name FROM `tabCost Center` WHERE `tabCost Center`.group_or_ledger="Ledger" AND `tabCost Center`.docstatus!=2 AND `tabCost Center`.company_name="'+doc.company+'" AND `tabCost Center`.%(key)s LIKE "%s"'
|
||||
}
|
||||
|
||||
//project name
|
||||
@@ -304,12 +300,6 @@ cur_frm.fields_dict['project_name'].get_query = function(doc, cdt, cdn) {
|
||||
query: "controllers.queries.get_project_name",
|
||||
filters: {'customer': doc.customer}
|
||||
}
|
||||
// var cond = '';
|
||||
// if(doc.customer) cond = '(`tabProject`.customer = "'+doc.customer+'" OR IFNULL(`tabProject`.customer,"")="") AND';
|
||||
// return repl('SELECT `tabProject`.name FROM `tabProject` \
|
||||
// WHERE `tabProject`.status not in ("Completed", "Cancelled") \
|
||||
// AND %(cond)s `tabProject`.name LIKE "%s" \
|
||||
// ORDER BY `tabProject`.name ASC LIMIT 50', {cond:cond});
|
||||
}
|
||||
|
||||
//Territory
|
||||
@@ -318,7 +308,6 @@ cur_frm.fields_dict['territory'].get_query = function(doc,cdt,cdn) {
|
||||
return{
|
||||
filters: {'is_group': 'NO'}
|
||||
}
|
||||
// return 'SELECT `tabTerritory`.`name`,`tabTerritory`.`parent_territory` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "No" AND `tabTerritory`.`docstatus`!= 2 AND `tabTerritory`.%(key)s LIKE "%s" ORDER BY `tabTerritory`.`name` ASC LIMIT 50';
|
||||
}
|
||||
|
||||
// Income Account in Details Table
|
||||
@@ -352,14 +341,12 @@ cur_frm.fields_dict['entries'].grid.get_field('warehouse').get_query= function(d
|
||||
['Bin', 'actual_qty', '>', 0]
|
||||
]
|
||||
}
|
||||
// return "SELECT `tabBin`.`warehouse`, `tabBin`.`actual_qty` FROM `tabBin` WHERE `tabBin`.`item_code` = '"+ d.item_code +"' AND ifnull(`tabBin`.`actual_qty`,0) > 0 AND `tabBin`.`warehouse` like '%s' ORDER BY `tabBin`.`warehouse` DESC LIMIT 50";
|
||||
}
|
||||
|
||||
// Cost Center in Details Table
|
||||
// -----------------------------
|
||||
cur_frm.fields_dict["entries"].grid.get_field("cost_center").get_query = function(doc) {
|
||||
return {
|
||||
// query: "accounts.utils.get_cost_center_list",
|
||||
filters: {
|
||||
'company_name': doc.company,
|
||||
'group_or_ledger': 'Ledger'
|
||||
|
||||
@@ -144,7 +144,6 @@ cur_frm.fields_dict['other_charges'].grid.get_field("account_head").get_query =
|
||||
['Account', 'company', '=', doc.company]
|
||||
]
|
||||
}
|
||||
// return 'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus != 2 AND tabAccount.account_type in ("Tax", "Chargeable", "Income Account") AND tabAccount.company = "'+doc.company+'" AND tabAccount.name LIKE "%s"'
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['other_charges'].grid.get_field("cost_center").get_query = function(doc) {
|
||||
@@ -152,7 +151,6 @@ cur_frm.fields_dict['other_charges'].grid.get_field("cost_center").get_query = f
|
||||
'company_name': doc.company,
|
||||
'group_or_ledger': "Ledger"
|
||||
}
|
||||
// return 'SELECT `tabCost Center`.`name` FROM `tabCost Center` WHERE `tabCost Center`.`company_name` = "' +doc.company+'" AND `tabCost Center`.%(key)s LIKE "%s" AND `tabCost Center`.`group_or_ledger` = "Ledger" AND `tabCost Center`.`docstatus`!= 2 ORDER BY `tabCost Center`.`name` ASC LIMIT 50';
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user