get_query to server side

This commit is contained in:
Saurabh
2013-07-08 18:45:55 +05:30
parent ed23cca9d3
commit 028755941e
18 changed files with 587 additions and 155 deletions

View File

@@ -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){

View File

@@ -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 }
}

View File

@@ -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}
}
}