mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-27 00:44:45 +00:00
[get_query]to server side
This commit is contained in:
@@ -51,39 +51,65 @@ cur_frm.cscript.item_code = function(doc) {
|
||||
|
||||
cur_frm.fields_dict['default_bom'].get_query = function(doc) {
|
||||
//var d = locals[this.doctype][this.docname];
|
||||
return 'SELECT DISTINCT `tabBOM`.`name` FROM `tabBOM` WHERE `tabBOM`.`item` = "' + doc.item_code + '" AND ifnull(`tabBOM`.`is_active`, 0) = 0 and `tabBOM`.docstatus != 2 AND `tabBOM`.%(key)s LIKE "%s" ORDER BY `tabBOM`.`name` LIMIT 50'
|
||||
return{
|
||||
filters:{
|
||||
'item': doc.item_code,
|
||||
'is_active': 0
|
||||
}
|
||||
}
|
||||
// return 'SELECT DISTINCT `tabBOM`.`name` FROM `tabBOM` WHERE `tabBOM`.`item` = "' + doc.item_code + '" AND ifnull(`tabBOM`.`is_active`, 0) = 0 and `tabBOM`.docstatus != 2 AND `tabBOM`.%(key)s LIKE "%s" ORDER BY `tabBOM`.`name` LIMIT 50'
|
||||
}
|
||||
|
||||
|
||||
// Expense Account
|
||||
// ---------------------------------
|
||||
cur_frm.fields_dict['purchase_account'].get_query = function(doc){
|
||||
return 'SELECT DISTINCT `tabAccount`.`name` FROM `tabAccount` WHERE `tabAccount`.`debit_or_credit`="Debit" AND `tabAccount`.`group_or_ledger`="Ledger" AND `tabAccount`.`docstatus`!=2 AND `tabAccount`.%(key)s LIKE "%s" ORDER BY `tabAccount`.`name` LIMIT 50'
|
||||
return{
|
||||
filters:{
|
||||
'debit_or_credit': "Debit",
|
||||
'group_or_ledger': "Ledger"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Income Account
|
||||
// --------------------------------
|
||||
cur_frm.fields_dict['default_income_account'].get_query = function(doc) {
|
||||
return 'SELECT DISTINCT `tabAccount`.`name` FROM `tabAccount` WHERE `tabAccount`.`debit_or_credit`="Credit" AND `tabAccount`.`group_or_ledger`="Ledger" AND `tabAccount`.`docstatus`!=2 AND `tabAccount`.`account_type` ="Income Account" AND `tabAccount`.%(key)s LIKE "%s" ORDER BY `tabAccount`.`name` LIMIT 50'
|
||||
return{
|
||||
filters:{
|
||||
'debit_or_credit': "Credit",
|
||||
'group_or_ledger': "Ledger",
|
||||
'account_type': "Income Account"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Purchase Cost Center
|
||||
// -----------------------------
|
||||
cur_frm.fields_dict['cost_center'].get_query = function(doc) {
|
||||
return 'SELECT `tabCost Center`.`name` FROM `tabCost Center` WHERE `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'
|
||||
return{
|
||||
filters:{ 'group_or_ledger': "Ledger" }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Sales Cost Center
|
||||
// -----------------------------
|
||||
cur_frm.fields_dict['default_sales_cost_center'].get_query = function(doc) {
|
||||
return 'SELECT `tabCost Center`.`name` FROM `tabCost Center` WHERE `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'
|
||||
return{
|
||||
filters:{ 'group_or_ledger': "Ledger" }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
cur_frm.fields_dict['item_tax'].grid.get_field("tax_type").get_query = function(doc, cdt, cdn) {
|
||||
return 'SELECT `tabAccount`.`name` FROM `tabAccount` WHERE `tabAccount`.`account_type` in ("Tax", "Chargeable") and `tabAccount`.`docstatus` != 2 and `tabAccount`.%(key)s LIKE "%s" ORDER BY `tabAccount`.`name` DESC LIMIT 50'
|
||||
return{
|
||||
filters:[
|
||||
['Account', 'account_type', 'in', 'Tax, Chargeable'],
|
||||
['Account', 'docstatus', '!=', 2]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript.tax_type = function(doc, cdt, cdn){
|
||||
@@ -94,10 +120,11 @@ cur_frm.cscript.tax_type = function(doc, cdt, cdn){
|
||||
|
||||
//get query select item group
|
||||
cur_frm.fields_dict['item_group'].get_query = function(doc,cdt,cdn) {
|
||||
return 'SELECT `tabItem Group`.`name`,`tabItem Group`.`parent_item_group` \
|
||||
FROM `tabItem Group` WHERE `tabItem Group`.`docstatus`!= 2 AND \
|
||||
`tabItem Group`.%(key)s LIKE "%s" ORDER BY `tabItem Group`.`name` \
|
||||
ASC LIMIT 50'
|
||||
return {
|
||||
filters: [
|
||||
['Item Group', 'docstatus', '!=', 2]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
// for description from attachment
|
||||
@@ -137,10 +164,12 @@ cur_frm.fields_dict['ref_rate_details'].grid.onrowadd = function(doc, cdt, cdn){
|
||||
}
|
||||
|
||||
cur_frm.fields_dict.item_customer_details.grid.get_field("customer_name").get_query =
|
||||
erpnext.utils.customer_query;
|
||||
function(doc,cdt,cdn) {
|
||||
return{ query:"controllers.queries.customer_query" } }
|
||||
|
||||
cur_frm.fields_dict.item_supplier_details.grid.get_field("supplier").get_query =
|
||||
erpnext.utils.supplier_query;
|
||||
function(doc,cdt,cdn) {
|
||||
return{ query:"controllers.queries.supplier_query" } }
|
||||
|
||||
cur_frm.cscript.on_remove_attachment = function(doc) {
|
||||
if(!inList(cur_frm.fields_dict.image.df.options.split("\n"), doc.image)) {
|
||||
|
||||
Reference in New Issue
Block a user