[get_query]to server side
This commit is contained in:
@@ -81,32 +81,56 @@ cur_frm.cscript.transaction = function(doc,cdt,cdn){
|
||||
}
|
||||
|
||||
|
||||
cur_frm.fields_dict.system_user.get_query = erpnext.utils.profile_query;
|
||||
cur_frm.fields_dict.system_user.get_query = function(doc,cdt,cdn) {
|
||||
return{ query:"controllers.queries.profile_query" } }
|
||||
|
||||
cur_frm.fields_dict.approving_user.get_query = erpnext.utils.profile_query;
|
||||
cur_frm.fields_dict.approving_user.get_query = function(doc,cdt,cdn) {
|
||||
return{ query:"controllers.queries.profile_query" } }
|
||||
|
||||
cur_frm.fields_dict['approving_role'].get_query = cur_frm.fields_dict['system_role'].get_query;
|
||||
|
||||
// System Role Trigger
|
||||
// -----------------------
|
||||
cur_frm.fields_dict['system_role'].get_query = function(doc) {
|
||||
return 'SELECT tabRole.name FROM tabRole WHERE tabRole.name not in ("Administrator","Guest","All") AND tabRole.%(key)s LIKE "%s" LIMIT 50'
|
||||
return{
|
||||
filters:[
|
||||
['Role', 'name', 'not in', 'Administrator, Guest, All']
|
||||
]
|
||||
}
|
||||
|
||||
// return 'SELECT tabRole.name FROM tabRole WHERE tabRole.name not in ("Administrator","Guest","All") AND tabRole.%(key)s LIKE "%s" LIMIT 50'
|
||||
}
|
||||
|
||||
// Approving Role Trigger
|
||||
// -----------------------
|
||||
cur_frm.fields_dict['approving_role'].get_query = function(doc) {
|
||||
return 'SELECT tabRole.name FROM tabRole WHERE tabRole.name not in ("Administrator","Guest","All") AND tabRole.%(key)s LIKE "%s" LIMIT 50'
|
||||
}
|
||||
// cur_frm.fields_dict['approving_role'].get_query = function(doc) {
|
||||
// return 'SELECT tabRole.name FROM tabRole WHERE tabRole.name not in ("Administrator","Guest","All") AND tabRole.%(key)s LIKE "%s" LIMIT 50'
|
||||
// }
|
||||
|
||||
|
||||
// Master Name Trigger
|
||||
// --------------------
|
||||
cur_frm.fields_dict['master_name'].get_query = function(doc){
|
||||
if(doc.based_on == 'Customerwise Discount')
|
||||
return 'SELECT `tabCustomer`.`name` FROM `tabCustomer` WHERE `tabCustomer`.docstatus !=2 and `tabCustomer`.`name` LIKE "%s" ORDER BY `tabCustomer`.`name` DESC LIMIT 50';
|
||||
return {
|
||||
filters:[
|
||||
['Customer', 'docstatus', '!=', 2]
|
||||
]
|
||||
}
|
||||
// return 'SELECT `tabCustomer`.`name` FROM `tabCustomer` WHERE `tabCustomer`.docstatus !=2 and `tabCustomer`.`name` LIKE "%s" ORDER BY `tabCustomer`.`name` DESC LIMIT 50';
|
||||
else if(doc.based_on == 'Itemwise Discount')
|
||||
return 'SELECT `tabItem`.`name` FROM `tabItem` WHERE (IFNULL(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` = "0000-00-00" OR `tabItem`.`end_of_life` > NOW()) and `tabItem`.is_sales_item = "Yes" and tabItem.%(key)s LIKE "%s" ORDER BY `tabItem`.`name` DESC LIMIT 50';
|
||||
return {
|
||||
query: "controllers.queries.item_query"
|
||||
}
|
||||
// return 'SELECT `tabItem`.`name` FROM `tabItem` WHERE (IFNULL(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` = "0000-00-00" OR `tabItem`.`end_of_life` > NOW()) and `tabItem`.is_sales_item = "Yes" and tabItem.%(key)s LIKE "%s" ORDER BY `tabItem`.`name` DESC LIMIT 50';
|
||||
else
|
||||
return 'SELECT `tabItem`.`name` FROM `tabItem` WHERE `tabItem`.`name` = "cheating done to avoid null" ORDER BY `tabItem`.`name` DESC LIMIT 50';
|
||||
return {
|
||||
filters: [
|
||||
['Item', 'name', '=', 'cheating done to avoid null']
|
||||
]
|
||||
}
|
||||
// return 'SELECT `tabItem`.`name` FROM `tabItem` WHERE `tabItem`.`name` = "cheating done to avoid null" ORDER BY `tabItem`.`name` DESC LIMIT 50';
|
||||
}
|
||||
|
||||
cur_frm.fields_dict.to_emp.get_query = erpnext.utils.employee_query;
|
||||
cur_frm.fields_dict.to_emp.get_query = function(doc,cdt,cdn) {
|
||||
return{ query:"controllers.queries.employee_query" } }
|
||||
@@ -45,43 +45,60 @@ cur_frm.cscript.abbr = function(doc){
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.fields_dict.default_cash_account.get_query = cur_frm.fields_dict.default_bank_account.get_query;
|
||||
|
||||
cur_frm.fields_dict.default_bank_account.get_query = function(doc) {
|
||||
return 'SELECT `tabAccount`.name, `tabAccount`.debit_or_credit, `tabAccount`.group_or_ledger FROM `tabAccount` WHERE `tabAccount`.company = "'+doc.name+'" AND `tabAccount`.group_or_ledger = "Ledger" AND `tabAccount`.docstatus != 2 AND `tabAccount`.account_type = "Bank or Cash" AND `tabAccount`.%(key)s LIKE "%s" ORDER BY `tabAccount`.name LIMIT 50';
|
||||
return{
|
||||
filters:{
|
||||
'company': doc.name,
|
||||
'group_or_ledger': "Ledger",
|
||||
'account_type': "Bank or Cash"
|
||||
}
|
||||
}
|
||||
// return 'SELECT `tabAccount`.name, `tabAccount`.debit_or_credit, `tabAccount`.group_or_ledger FROM `tabAccount` WHERE `tabAccount`.company = "'+doc.name+'" AND `tabAccount`.group_or_ledger = "Ledger" AND `tabAccount`.docstatus != 2 AND `tabAccount`.account_type = "Bank or Cash" AND `tabAccount`.%(key)s LIKE "%s" ORDER BY `tabAccount`.name LIMIT 50';
|
||||
}
|
||||
|
||||
cur_frm.fields_dict.default_cash_account.get_query = function(doc) {
|
||||
return 'SELECT `tabAccount`.name, `tabAccount`.debit_or_credit, `tabAccount`.group_or_ledger FROM `tabAccount` WHERE `tabAccount`.company = "'+doc.name+'" AND `tabAccount`.group_or_ledger = "Ledger" AND `tabAccount`.docstatus != 2 AND `tabAccount`.account_type = "Bank or Cash" AND `tabAccount`.%(key)s LIKE "%s" ORDER BY `tabAccount`.name LIMIT 50';
|
||||
}
|
||||
// cur_frm.fields_dict.default_cash_account.get_query = function(doc) {
|
||||
// return 'SELECT `tabAccount`.name, `tabAccount`.debit_or_credit, `tabAccount`.group_or_ledger FROM `tabAccount` WHERE `tabAccount`.company = "'+doc.name+'" AND `tabAccount`.group_or_ledger = "Ledger" AND `tabAccount`.docstatus != 2 AND `tabAccount`.account_type = "Bank or Cash" AND `tabAccount`.%(key)s LIKE "%s" ORDER BY `tabAccount`.name LIMIT 50';
|
||||
// }
|
||||
|
||||
cur_frm.fields_dict.payables_group.get_query = cur_frm.fields_dict.receivables_group.get_query;
|
||||
|
||||
cur_frm.fields_dict.receivables_group.get_query = function(doc) {
|
||||
return 'SELECT `tabAccount`.name FROM `tabAccount` WHERE `tabAccount`.company = "'+doc.name+'" AND `tabAccount`.group_or_ledger = "Group" AND `tabAccount`.docstatus != 2 AND `tabAccount`.%(key)s LIKE "%s" ORDER BY `tabAccount`.name LIMIT 50';
|
||||
return{
|
||||
filters:{
|
||||
'company': doc.name,
|
||||
'group_or_ledger': "Group"
|
||||
}
|
||||
}
|
||||
// return 'SELECT `tabAccount`.name FROM `tabAccount` WHERE `tabAccount`.company = "'+doc.name+'" AND `tabAccount`.group_or_ledger = "Group" AND `tabAccount`.docstatus != 2 AND `tabAccount`.%(key)s LIKE "%s" ORDER BY `tabAccount`.name LIMIT 50';
|
||||
}
|
||||
|
||||
|
||||
cur_frm.fields_dict.payables_group.get_query = function(doc) {
|
||||
return 'SELECT `tabAccount`.name FROM `tabAccount` WHERE `tabAccount`.company = "'+doc.name+'" AND `tabAccount`.group_or_ledger = "Group" AND `tabAccount`.docstatus != 2 AND `tabAccount`.%(key)s LIKE "%s" ORDER BY `tabAccount`.name LIMIT 50';
|
||||
}
|
||||
// cur_frm.fields_dict.payables_group.get_query = function(doc) {
|
||||
// return 'SELECT `tabAccount`.name FROM `tabAccount` WHERE `tabAccount`.company = "'+doc.name+'" AND `tabAccount`.group_or_ledger = "Group" AND `tabAccount`.docstatus != 2 AND `tabAccount`.%(key)s LIKE "%s" ORDER BY `tabAccount`.name LIMIT 50';
|
||||
// }
|
||||
|
||||
if (sys_defaults.auto_inventory_accounting) {
|
||||
cur_frm.fields_dict["stock_in_hand_account"].get_query = function(doc) {
|
||||
return {
|
||||
"query": "accounts.utils.get_account_list",
|
||||
// "query": "accounts.utils.get_account_list",
|
||||
"filters": {
|
||||
"is_pl_account": "No",
|
||||
"debit_or_credit": "Debit",
|
||||
"company": doc.name
|
||||
"company": doc.name,
|
||||
'group_or_ledger': "Ledger"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.fields_dict["stock_adjustment_account"].get_query = function(doc) {
|
||||
return {
|
||||
"query": "accounts.utils.get_account_list",
|
||||
// "query": "accounts.utils.get_account_list",
|
||||
"filters": {
|
||||
"is_pl_account": "Yes",
|
||||
"debit_or_credit": "Debit",
|
||||
"company": doc.name
|
||||
"company": doc.name,
|
||||
'group_or_ledger': "Ledger"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -91,18 +108,19 @@ if (sys_defaults.auto_inventory_accounting) {
|
||||
|
||||
cur_frm.fields_dict["stock_received_but_not_billed"].get_query = function(doc) {
|
||||
return {
|
||||
"query": "accounts.utils.get_account_list",
|
||||
// "query": "accounts.utils.get_account_list",
|
||||
"filters": {
|
||||
"is_pl_account": "No",
|
||||
"debit_or_credit": "Credit",
|
||||
"company": doc.name
|
||||
"company": doc.name,
|
||||
'group_or_ledger': "Ledger"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.fields_dict["stock_adjustment_cost_center"].get_query = function(doc) {
|
||||
return {
|
||||
"query": "accounts.utils.get_cost_center_list",
|
||||
// "query": "accounts.utils.get_cost_center_list",
|
||||
"filters": {"company": doc.name}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,12 @@ cur_frm.cscript.country = function(doc, dt, dn) {
|
||||
// ---------------------------
|
||||
if(cur_frm.fields_dict['territory']){
|
||||
cur_frm.fields_dict['territory'].get_query = function(doc,dt,dn) {
|
||||
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';
|
||||
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';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,8 +30,14 @@ cur_frm.cscript.set_root_readonly = function(doc) {
|
||||
|
||||
//get query select Customer Group
|
||||
cur_frm.fields_dict['parent_customer_group'].get_query = function(doc,cdt,cdn) {
|
||||
return 'SELECT `tabCustomer Group`.`name`,`tabCustomer Group`.`parent_customer_group` \
|
||||
FROM `tabCustomer Group` WHERE `tabCustomer Group`.`is_group` = "Yes" AND \
|
||||
`tabCustomer Group`.`docstatus`!= 2 AND `tabCustomer Group`.%(key)s LIKE "%s" \
|
||||
ORDER BY `tabCustomer Group`.`name` ASC LIMIT 50';
|
||||
return{
|
||||
searchfield:['name', 'parent_customer_group'],
|
||||
filters: {
|
||||
'is_group': "Yes"
|
||||
}
|
||||
}
|
||||
// return 'SELECT `tabCustomer Group`.`name`,`tabCustomer Group`.`parent_customer_group` \
|
||||
// FROM `tabCustomer Group` WHERE `tabCustomer Group`.`is_group` = "Yes" AND \
|
||||
// `tabCustomer Group`.`docstatus`!= 2 AND `tabCustomer Group`.%(key)s LIKE "%s" \
|
||||
// ORDER BY `tabCustomer Group`.`name` ASC LIMIT 50';
|
||||
}
|
||||
@@ -34,5 +34,11 @@ cur_frm.cscript.set_root_readonly = function(doc) {
|
||||
|
||||
//get query select item group
|
||||
cur_frm.fields_dict['parent_item_group'].get_query = function(doc,cdt,cdn) {
|
||||
return 'SELECT `tabItem Group`.`name`,`tabItem Group`.`parent_item_group` FROM `tabItem Group` WHERE `tabItem Group`.`is_group` = "Yes" AND `tabItem Group`.`docstatus`!= 2 AND `tabItem Group`.`name` !="'+doc.item_group_name+'" AND `tabItem Group`.%(key)s LIKE "%s" ORDER BY `tabItem Group`.`name` ASC LIMIT 50';
|
||||
return{
|
||||
filters:[
|
||||
['Item Group', 'is_group', '=', 'Yes'],
|
||||
['Item Group', 'naem', '!=', doc.item_group_name]
|
||||
]
|
||||
}
|
||||
// return 'SELECT `tabItem Group`.`name`,`tabItem Group`.`parent_item_group` FROM `tabItem Group` WHERE `tabItem Group`.`is_group` = "Yes" AND `tabItem Group`.`docstatus`!= 2 AND `tabItem Group`.`name` !="'+doc.item_group_name+'" AND `tabItem Group`.%(key)s LIKE "%s" ORDER BY `tabItem Group`.`name` ASC LIMIT 50';
|
||||
}
|
||||
@@ -97,5 +97,8 @@ cur_frm.cscript.make_contact = function() {
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['partner_target_details'].grid.get_field("item_group").get_query = function(doc, dt, dn) {
|
||||
return 'SELECT `tabItem Group`.`name`,`tabItem Group`.`parent_item_group` FROM `tabItem Group` WHERE `tabItem Group`.is_group="No" AND `tabItem Group`.docstatus != 2 AND `tabItem Group`.%(key)s LIKE "%s" LIMIT 50'
|
||||
return{
|
||||
filters:{ 'is_group': "No" }
|
||||
}
|
||||
// return 'SELECT `tabItem Group`.`name`,`tabItem Group`.`parent_item_group` FROM `tabItem Group` WHERE `tabItem Group`.is_group="No" AND `tabItem Group`.docstatus != 2 AND `tabItem Group`.%(key)s LIKE "%s" LIMIT 50'
|
||||
}
|
||||
@@ -35,11 +35,21 @@ cur_frm.cscript.onload = function(){
|
||||
|
||||
//get query select sales person
|
||||
cur_frm.fields_dict['parent_sales_person'].get_query = function(doc,cdt,cdn) {
|
||||
return 'SELECT `tabSales Person`.`name`,`tabSales Person`.`parent_sales_person` FROM `tabSales Person` WHERE `tabSales Person`.`is_group` = "Yes" AND `tabSales Person`.`docstatus`!= 2 AND `tabSales Person`.`name` !="'+doc.sales_person_name+'" AND `tabSales Person`.%(key)s LIKE "%s" ORDER BY `tabSales Person`.`name` ASC LIMIT 50';
|
||||
return{
|
||||
filters:[
|
||||
['Sales Person', 'is_group', '=', 'Yes'],
|
||||
['Sales Person', 'name', '!=', doc.sales_person_name]
|
||||
]
|
||||
}
|
||||
// return 'SELECT `tabSales Person`.`name`,`tabSales Person`.`parent_sales_person` FROM `tabSales Person` WHERE `tabSales Person`.`is_group` = "Yes" AND `tabSales Person`.`docstatus`!= 2 AND `tabSales Person`.`name` !="'+doc.sales_person_name+'" AND `tabSales Person`.%(key)s LIKE "%s" ORDER BY `tabSales Person`.`name` ASC LIMIT 50';
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['target_details'].grid.get_field("item_group").get_query = function(doc, cdt, cdn) {
|
||||
return 'SELECT `tabItem Group`.name FROM `tabItem Group` WHERE `tabItem Group`.is_group="No" AND `tabItem Group`.docstatus != 2 AND `tabItem Group`.%(key)s LIKE "%s" LIMIT 50'
|
||||
return{
|
||||
filters:{ 'is_group': "No" }
|
||||
}
|
||||
// return 'SELECT `tabItem Group`.name FROM `tabItem Group` WHERE `tabItem Group`.is_group="No" AND `tabItem Group`.docstatus != 2 AND `tabItem Group`.%(key)s LIKE "%s" LIMIT 50'
|
||||
}
|
||||
|
||||
cur_frm.fields_dict.employee.get_query = erpnext.utils.employee_query;
|
||||
cur_frm.fields_dict.employee.get_query = function(doc,cdt,cdn) {
|
||||
return{ query:"controllers.queries.employee_query" } }
|
||||
@@ -30,11 +30,20 @@ cur_frm.cscript.set_root_readonly = function(doc) {
|
||||
|
||||
//get query select territory
|
||||
cur_frm.fields_dict['parent_territory'].get_query = function(doc,cdt,cdn) {
|
||||
return 'SELECT `tabTerritory`.`name`,`tabTerritory`.`parent_territory` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "Yes" AND `tabTerritory`.`docstatus`!= 2 AND `tabTerritory`.`name` !="'+doc.territory_name+'" AND `tabTerritory`.%(key)s LIKE "%s" ORDER BY `tabTerritory`.`name` ASC LIMIT 50';
|
||||
return{
|
||||
filters:[
|
||||
['Territory', 'is_group', '=', 'Yes'],
|
||||
['Territory', 'name', '!=', doc.territory_name]
|
||||
]
|
||||
}
|
||||
// return 'SELECT `tabTerritory`.`name`,`tabTerritory`.`parent_territory` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "Yes" AND `tabTerritory`.`docstatus`!= 2 AND `tabTerritory`.`name` !="'+doc.territory_name+'" AND `tabTerritory`.%(key)s LIKE "%s" ORDER BY `tabTerritory`.`name` ASC LIMIT 50';
|
||||
}
|
||||
|
||||
|
||||
// ******************** ITEM Group ********************************
|
||||
cur_frm.fields_dict['target_details'].grid.get_field("item_group").get_query = function(doc, cdt, cdn) {
|
||||
return 'SELECT `tabItem Group`.`name`,`tabItem Group`.`parent_item_group` FROM `tabItem Group` WHERE `tabItem Group`.is_group="No" AND `tabItem Group`.docstatus != 2 AND `tabItem Group`.%(key)s LIKE "%s" LIMIT 50'
|
||||
return{
|
||||
filters:{ 'is_group': "No"}
|
||||
}
|
||||
// return 'SELECT `tabItem Group`.`name`,`tabItem Group`.`parent_item_group` FROM `tabItem Group` WHERE `tabItem Group`.is_group="No" AND `tabItem Group`.docstatus != 2 AND `tabItem Group`.%(key)s LIKE "%s" LIMIT 50'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user