mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-03 12:19:12 +00:00
get_query to server side
This commit is contained in:
@@ -80,25 +80,37 @@ cur_frm.cscript.supplier_address = cur_frm.cscript.contact_person = function(doc
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['supplier_address'].get_query = function(doc, cdt, cdn) {
|
||||
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';
|
||||
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 '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';
|
||||
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['po_details'].grid.get_field('project_name').get_query = function(doc, cdt, cdn) {
|
||||
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';
|
||||
return {
|
||||
filters:[
|
||||
['Project', 'status', 'not in', 'Completed, Cancelled']
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['indent_no'].get_query = function(doc) {
|
||||
return 'SELECT DISTINCT `name` FROM `tabMaterial Request` \
|
||||
WHERE material_request_type="Purchase" and company = "' + doc.company
|
||||
+ '" and `docstatus` = 1 and `status` != "Stopped" \
|
||||
and ifnull(`per_ordered`,0) < 99.99 and %(key)s LIKE "%s" \
|
||||
ORDER BY `name` DESC LIMIT 50';
|
||||
return{
|
||||
filters:[
|
||||
['Material Request', 'material_request_type', '=', 'Purchase'],
|
||||
['Material Request', 'company', '=', doc.company],
|
||||
['Material Request', 'docstatus', '=', '1'],
|
||||
['Material Request', 'status', '!=', 'Stopped'],
|
||||
['Material Request', 'per_ordered', '<', 99.99]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript.get_last_purchase_rate = function(doc, cdt, cdn){
|
||||
|
||||
@@ -43,18 +43,33 @@ cur_frm.cscript.refresh = cur_frm.cscript.inspection_type;
|
||||
|
||||
// item code based on GRN/DN
|
||||
cur_frm.fields_dict['item_code'].get_query = function(doc, cdt, cdn) {
|
||||
filter = {};
|
||||
if (doc.purchase_receipt_no)
|
||||
return 'SELECT item_code, item_name, description FROM `tabPurchase Receipt Item` WHERE parent = "'+ doc.purchase_receipt_no +'" and docstatus != 2 AND item_code LIKE "%s" ORDER BY item_code ASC LIMIT 50';
|
||||
filter:{
|
||||
'parent': doc.purchase_receipt_no
|
||||
}
|
||||
// return 'SELECT item_code, item_name, description FROM `tabPurchase Receipt Item` WHERE parent = "'+ doc.purchase_receipt_no +'" and docstatus != 2 AND item_code LIKE "%s" ORDER BY item_code ASC LIMIT 50';
|
||||
else if (doc.delivery_note_no)
|
||||
return 'SELECT item_code, item_name, description FROM `tabDelivery Note Item` WHERE parent = "'+ doc.delivery_note_no +'" and docstatus != 2 AND item_code LIKE "%s" ORDER BY item_code ASC LIMIT 50';
|
||||
else
|
||||
return 'SELECT name, item_name, description FROM tabItem WHERE docstatus != 2 AND %(key)s LIKE "%s" ORDER BY name ASC LIMIT 50';
|
||||
filter:{
|
||||
'parent': doc.delivery_note_no
|
||||
}
|
||||
// return 'SELECT item_code, item_name, description FROM `tabDelivery Note Item` WHERE parent = "'+ doc.delivery_note_no +'" and docstatus != 2 AND item_code LIKE "%s" ORDER BY item_code ASC LIMIT 50';
|
||||
return{
|
||||
filters: filter
|
||||
}
|
||||
}
|
||||
|
||||
// Serial No based on item_code
|
||||
cur_frm.fields_dict['item_serial_no'].get_query = function(doc, cdt, cdn) {
|
||||
filter = {};
|
||||
if (doc.item_code)
|
||||
return 'SELECT name, item_code, warehouse FROM `tabSerial No` WHERE docstatus != 2 AND item_code = "' + doc.item_code +'" AND status = "In Store" AND %(key)s LIKE "%s" ORDER BY name ASC LIMIT 50';
|
||||
filter:{
|
||||
'item_code': doc.item_code,
|
||||
'status': "In Store"
|
||||
}
|
||||
// return 'SELECT name, item_code, warehouse FROM `tabSerial No` WHERE docstatus != 2 AND item_code = "' + doc.item_code +'" AND status = "In Store" AND %(key)s LIKE "%s" ORDER BY name ASC LIMIT 50';
|
||||
else
|
||||
return 'SELECT name, item_code, warehouse FROM `tabSerial No` WHERE docstatus != 2 AND status = "In Store" AND %(key)s LIKE "%s" ORDER BY name ASC LIMIT 50';
|
||||
}
|
||||
filter:{ 'status': "In Store" }
|
||||
// return 'SELECT name, item_code, warehouse FROM `tabSerial No` WHERE docstatus != 2 AND status = "In Store" AND %(key)s LIKE "%s" ORDER BY name ASC LIMIT 50';
|
||||
return{ filters: filter }
|
||||
}
|
||||
@@ -56,18 +56,23 @@ cur_frm.cscript.uom = function(doc, cdt, cdn) {
|
||||
|
||||
cur_frm.fields_dict['quotation_items'].grid.get_field('project_name').get_query =
|
||||
function(doc, cdt, cdn) {
|
||||
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";
|
||||
return{
|
||||
filters:[
|
||||
['Project', 'status', 'not in', 'Completed, Cancelled'],
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['indent_no'].get_query = function(doc) {
|
||||
return "select distinct `name` from `tabMaterial Request` \
|
||||
where material_request_type='Purchase' and company = \"" + doc.company +
|
||||
"\" and `docstatus` = 1 and `status` != \"Stopped\" and \
|
||||
ifnull(`per_ordered`,0) < 99.99 and \
|
||||
%(key)s LIKE \"%s\" order by `name` desc limit 50";
|
||||
return{
|
||||
filters:[
|
||||
['Material Request', 'material_request_type', '=', 'Purchase'],
|
||||
['Material Request', 'company', '=', doc.company],
|
||||
['Material Request', 'docstatus', '=', 1],
|
||||
['Material Request', 'status', '!=', 'Stopped'],
|
||||
['Material Request', 'per_ordered', '<', 99.99]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript.supplier_address = function(doc, dt, dn) {
|
||||
@@ -79,12 +84,13 @@ cur_frm.cscript.supplier_address = function(doc, dt, dn) {
|
||||
cur_frm.cscript.contact_person = cur_frm.cscript.supplier_address;
|
||||
|
||||
cur_frm.fields_dict['supplier_address'].get_query = function(doc, cdt, cdn) {
|
||||
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";
|
||||
return {
|
||||
filters:{'supplier': doc.supplier}
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['contact_person'].get_query = function(doc, cdt, cdn) {
|
||||
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";
|
||||
return {
|
||||
filters:{'supplier': doc.supplier}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user