[conflict] merged for get_query

This commit is contained in:
Nabin Hait
2013-07-10 19:05:57 +05:30
72 changed files with 1243 additions and 432 deletions

View File

@@ -28,27 +28,37 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
if(this.frm.fields_dict.price_list_name) {
this.frm.set_query("price_list_name", function() {
return repl("select name, currency from `tabPrice List` \
where buying_or_selling = 'Buying' and name like \"%s%%\"");
return{
filters: { 'buying_or_selling': "Buying" }
}
});
this.frm.set_query("price_list_currency", function() {
return repl("select distinct ref_currency from `tabItem Price` \
where price_list_name=\"%(price_list_name)s\" and buying_or_selling = 'Buying' \
and ref_currency like \"%s%%\"",
{price_list_name: me.frm.doc.price_list_name});
return{
filters: {
'price_list_name': me.frm.doc.price_list_name,
'buying_or_selling': "Buying"
}
}
});
}
if(this.frm.fields_dict.supplier) {
this.frm.set_query("supplier", erpnext.utils.supplier_query);
this.frm.set_query("supplier", function() {
return{ query:"controllers.queries.supplier_query" }});
}
this.frm.set_query("item_code", this.frm.cscript.fname, function() {
if(me.frm.doc.is_subcontracted == "Yes") {
return erpnext.queries.item({'ifnull(tabItem.is_sub_contracted_item, "No")': "Yes"});
return{
query:"controllers.queries.item_query",
filters:{ 'is_sub_contracted_item': 'Yes' }
}
} else {
return erpnext.queries.item({'ifnull(tabItem.is_purchase_item, "No")': "Yes"});
return{
query: "controllers.queries.item_query",
filters: { 'is_purchase_item': 'Yes' }
}
}
});
},

View File

@@ -110,17 +110,23 @@ 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}
}
}
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}
}
}
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.cscript.get_last_purchase_rate = function(doc, cdt, cdn){

View File

@@ -43,18 +43,26 @@ 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) {
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';
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';
var filter = {};
if (doc.purchase_receipt_no) filter['parent'] = doc.purchase_receipt_no;
else if (doc.delivery_note_no) filter['parent'] = doc.delivery_note_no;
return{
filters: filter
}
}
// Serial No based on item_code
cur_frm.fields_dict['item_serial_no'].get_query = function(doc, cdt, cdn) {
var 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"
}
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 { filters: filter }
}

View File

@@ -65,10 +65,11 @@ 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.cscript.supplier_address = function(doc, dt, dn) {
@@ -80,12 +81,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}
}
}