From 68764ce775a0c0c9f7b89fe50b7f0ba9ef323e68 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 26 Mar 2012 11:16:41 +0530 Subject: [PATCH 1/8] modified item code get_query in purchase cycle --- erpnext/buying/doctype/purchase_common/purchase_common.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/buying/doctype/purchase_common/purchase_common.js b/erpnext/buying/doctype/purchase_common/purchase_common.js index f258f110ed..b1c88f6626 100644 --- a/erpnext/buying/doctype/purchase_common/purchase_common.js +++ b/erpnext/buying/doctype/purchase_common/purchase_common.js @@ -162,7 +162,7 @@ cur_frm.cscript.conversion_rate = function(doc,cdt,cdn) { //==================== Item Code Get Query ======================================================= // Only Is Purchase Item = 'Yes' and Items not moved to trash are allowed. cur_frm.fields_dict[fname].grid.get_field("item_code").get_query = function(doc, cdt, cdn) { - return 'SELECT tabItem.name, tabItem.description FROM tabItem WHERE (ifnull(tabItem.is_purchase_item, "No")="Yes" or ifnull(tabItem.is_sub_contracted_item, "No")="Yes") AND (IFNULL(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` ="0000-00-00" OR `tabItem`.`end_of_life` > NOW()) AND tabItem.docstatus != 2 AND tabItem.%(key)s LIKE "%s" LIMIT 50' + return 'SELECT tabItem.name, tabItem.description FROM tabItem WHERE (ifnull(tabItem.is_purchase_item, "No")="Yes" or ifnull(tabItem.is_sub_contracted_item, "No")="' + (doc.is_subcontracted=="Yes"?"Yes":"No") + '") AND (IFNULL(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` ="0000-00-00" OR `tabItem`.`end_of_life` > NOW()) AND tabItem.docstatus != 2 AND tabItem.%(key)s LIKE "%s" LIMIT 50' } //==================== Get Item Code Details ===================================================== From 2bd086f1c346f4e39c799377a94eefa7da78c252 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 26 Mar 2012 11:25:31 +0530 Subject: [PATCH 2/8] modified item code get_query in purchase cycle --- erpnext/buying/doctype/purchase_common/purchase_common.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/buying/doctype/purchase_common/purchase_common.js b/erpnext/buying/doctype/purchase_common/purchase_common.js index b1c88f6626..f258f110ed 100644 --- a/erpnext/buying/doctype/purchase_common/purchase_common.js +++ b/erpnext/buying/doctype/purchase_common/purchase_common.js @@ -162,7 +162,7 @@ cur_frm.cscript.conversion_rate = function(doc,cdt,cdn) { //==================== Item Code Get Query ======================================================= // Only Is Purchase Item = 'Yes' and Items not moved to trash are allowed. cur_frm.fields_dict[fname].grid.get_field("item_code").get_query = function(doc, cdt, cdn) { - return 'SELECT tabItem.name, tabItem.description FROM tabItem WHERE (ifnull(tabItem.is_purchase_item, "No")="Yes" or ifnull(tabItem.is_sub_contracted_item, "No")="' + (doc.is_subcontracted=="Yes"?"Yes":"No") + '") AND (IFNULL(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` ="0000-00-00" OR `tabItem`.`end_of_life` > NOW()) AND tabItem.docstatus != 2 AND tabItem.%(key)s LIKE "%s" LIMIT 50' + return 'SELECT tabItem.name, tabItem.description FROM tabItem WHERE (ifnull(tabItem.is_purchase_item, "No")="Yes" or ifnull(tabItem.is_sub_contracted_item, "No")="Yes") AND (IFNULL(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` ="0000-00-00" OR `tabItem`.`end_of_life` > NOW()) AND tabItem.docstatus != 2 AND tabItem.%(key)s LIKE "%s" LIMIT 50' } //==================== Get Item Code Details ===================================================== From ea36202fbf8130d9a640413c78fe104fc95c7929 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 26 Mar 2012 11:33:03 +0530 Subject: [PATCH 3/8] modified item code get_query in purchase cycle --- erpnext/buying/doctype/purchase_common/purchase_common.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/buying/doctype/purchase_common/purchase_common.js b/erpnext/buying/doctype/purchase_common/purchase_common.js index f258f110ed..ad822b5ab0 100644 --- a/erpnext/buying/doctype/purchase_common/purchase_common.js +++ b/erpnext/buying/doctype/purchase_common/purchase_common.js @@ -162,7 +162,7 @@ cur_frm.cscript.conversion_rate = function(doc,cdt,cdn) { //==================== Item Code Get Query ======================================================= // Only Is Purchase Item = 'Yes' and Items not moved to trash are allowed. cur_frm.fields_dict[fname].grid.get_field("item_code").get_query = function(doc, cdt, cdn) { - return 'SELECT tabItem.name, tabItem.description FROM tabItem WHERE (ifnull(tabItem.is_purchase_item, "No")="Yes" or ifnull(tabItem.is_sub_contracted_item, "No")="Yes") AND (IFNULL(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` ="0000-00-00" OR `tabItem`.`end_of_life` > NOW()) AND tabItem.docstatus != 2 AND tabItem.%(key)s LIKE "%s" LIMIT 50' + return 'SELECT tabItem.name, tabItem.description FROM tabItem WHERE (ifnull(tabItem.is_purchase_item, "No")="Yes"'+ (doc.is_sucontracted=="Yes" ? ' AND ifnull(tabItem.is_sub_contracted_item, "No")="Yes"' : '') + ' AND (IFNULL(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` ="0000-00-00" OR `tabItem`.`end_of_life` > NOW()) AND tabItem.docstatus != 2 AND tabItem.%(key)s LIKE "%s" LIMIT 50' } //==================== Get Item Code Details ===================================================== From 9329b5a461bb49200b2a1cbca0c8d13692b609ba Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 26 Mar 2012 11:52:16 +0530 Subject: [PATCH 4/8] modified item code get_query in purchase cycle --- erpnext/buying/doctype/purchase_common/purchase_common.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/buying/doctype/purchase_common/purchase_common.js b/erpnext/buying/doctype/purchase_common/purchase_common.js index ad822b5ab0..8c3bb3ba35 100644 --- a/erpnext/buying/doctype/purchase_common/purchase_common.js +++ b/erpnext/buying/doctype/purchase_common/purchase_common.js @@ -162,7 +162,7 @@ cur_frm.cscript.conversion_rate = function(doc,cdt,cdn) { //==================== Item Code Get Query ======================================================= // Only Is Purchase Item = 'Yes' and Items not moved to trash are allowed. cur_frm.fields_dict[fname].grid.get_field("item_code").get_query = function(doc, cdt, cdn) { - return 'SELECT tabItem.name, tabItem.description FROM tabItem WHERE (ifnull(tabItem.is_purchase_item, "No")="Yes"'+ (doc.is_sucontracted=="Yes" ? ' AND ifnull(tabItem.is_sub_contracted_item, "No")="Yes"' : '') + ' AND (IFNULL(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` ="0000-00-00" OR `tabItem`.`end_of_life` > NOW()) AND tabItem.docstatus != 2 AND tabItem.%(key)s LIKE "%s" LIMIT 50' + return 'SELECT tabItem.name, tabItem.description FROM tabItem WHERE ifnull(tabItem.is_purchase_item, "No")="Yes"'+ (doc.is_subcontracted=="Yes" ? ' AND ifnull(tabItem.is_sub _contracted_item, "No")="Yes"' : '') + ' AND (IFNULL(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` ="0000-00-00" OR `tabItem`.`end_of_life` > NOW()) AND tabItem.do cstatus != 2 AND tabItem.%(key)s LIKE "%s" LIMIT 50' } //==================== Get Item Code Details ===================================================== From eecea8ef194bd524f0d49e4a9710f67ae086674e Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 26 Mar 2012 13:11:15 +0530 Subject: [PATCH 5/8] modified item code get_query in purchase cycle --- erpnext/buying/doctype/purchase_common/purchase_common.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/buying/doctype/purchase_common/purchase_common.js b/erpnext/buying/doctype/purchase_common/purchase_common.js index 8c3bb3ba35..9adb08a8ae 100644 --- a/erpnext/buying/doctype/purchase_common/purchase_common.js +++ b/erpnext/buying/doctype/purchase_common/purchase_common.js @@ -162,7 +162,7 @@ cur_frm.cscript.conversion_rate = function(doc,cdt,cdn) { //==================== Item Code Get Query ======================================================= // Only Is Purchase Item = 'Yes' and Items not moved to trash are allowed. cur_frm.fields_dict[fname].grid.get_field("item_code").get_query = function(doc, cdt, cdn) { - return 'SELECT tabItem.name, tabItem.description FROM tabItem WHERE ifnull(tabItem.is_purchase_item, "No")="Yes"'+ (doc.is_subcontracted=="Yes" ? ' AND ifnull(tabItem.is_sub _contracted_item, "No")="Yes"' : '') + ' AND (IFNULL(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` ="0000-00-00" OR `tabItem`.`end_of_life` > NOW()) AND tabItem.do cstatus != 2 AND tabItem.%(key)s LIKE "%s" LIMIT 50' + return 'SELECT tabItem.name, tabItem.description FROM tabItem WHERE ifnull(tabItem.is_purchase_item, "No")="Yes"'+ (doc.is_subcontracted=="Yes" ? ' AND ifnull(tabItem.is_sub_contracted_item, "No")="Yes"' : '') + ' AND (IFNULL(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` ="0000-00-00" OR `tabItem`.`end_of_life` > NOW()) AND tabItem.docstatus != 2 AND tabItem.%(key)s LIKE "%s" LIMIT 50' } //==================== Get Item Code Details ===================================================== From b66ade11e0974347731b09b8ab24f6f27f8f4deb Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 26 Mar 2012 15:30:11 +0530 Subject: [PATCH 6/8] modified item code get_query in purchase cycle --- erpnext/buying/doctype/purchase_common/purchase_common.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/erpnext/buying/doctype/purchase_common/purchase_common.js b/erpnext/buying/doctype/purchase_common/purchase_common.js index 9adb08a8ae..89094e9a00 100644 --- a/erpnext/buying/doctype/purchase_common/purchase_common.js +++ b/erpnext/buying/doctype/purchase_common/purchase_common.js @@ -162,7 +162,11 @@ cur_frm.cscript.conversion_rate = function(doc,cdt,cdn) { //==================== Item Code Get Query ======================================================= // Only Is Purchase Item = 'Yes' and Items not moved to trash are allowed. cur_frm.fields_dict[fname].grid.get_field("item_code").get_query = function(doc, cdt, cdn) { - return 'SELECT tabItem.name, tabItem.description FROM tabItem WHERE ifnull(tabItem.is_purchase_item, "No")="Yes"'+ (doc.is_subcontracted=="Yes" ? ' AND ifnull(tabItem.is_sub_contracted_item, "No")="Yes"' : '') + ' AND (IFNULL(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` ="0000-00-00" OR `tabItem`.`end_of_life` > NOW()) AND tabItem.docstatus != 2 AND tabItem.%(key)s LIKE "%s" LIMIT 50' + if (doc.is_subcontracted =="Yes") { + return 'SELECT tabItem.name, tabItem.description FROM tabItem WHERE ifnull(tabItem.is_sub_contracted_item, "No")="Yes" AND (IFNULL(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` ="0000-00-00" OR `tabItem`.`end_of_life` > NOW()) AND tabItem.docstatus != 2 AND tabItem.%(key)s LIKE "%s" LIMIT 50' + } else { + return 'SELECT tabItem.name, tabItem.description FROM tabItem WHERE ifnull(tabItem.is_purchase_item, "No")="Yes" AND (IFNULL(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` ="0000-00-00" OR `tabItem`.`end_of_life` > NOW()) AND tabItem.docstatus != 2 AND tabItem.%(key)s LIKE "%s" LIMIT 50' + } } //==================== Get Item Code Details ===================================================== From 854935f12c9a11df9b363ac2d58c2a3e25ee39a1 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 26 Mar 2012 15:40:56 +0530 Subject: [PATCH 7/8] added docstatus in item get_query in PV --- erpnext/accounts/doctype/payable_voucher/payable_voucher.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/payable_voucher/payable_voucher.js b/erpnext/accounts/doctype/payable_voucher/payable_voucher.js index f8ef91ec3e..0bba213137 100644 --- a/erpnext/accounts/doctype/payable_voucher/payable_voucher.js +++ b/erpnext/accounts/doctype/payable_voucher/payable_voucher.js @@ -254,7 +254,7 @@ cur_frm.fields_dict['contact_person'].get_query = function(doc, cdt, cdn) { // Item Code // ---------- cur_frm.fields_dict['entries'].grid.get_field("item_code").get_query = function(doc, cdt, cdn) { - return 'SELECT tabItem.name, tabItem.description FROM tabItem WHERE tabItem.is_purchase_item="Yes" AND (IFNULL(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` ="0000-00-00" OR `tabItem`.`end_of_life` > NOW()) AND tabItem.%(key)s LIKE "%s" LIMIT 50' + return 'SELECT tabItem.name, tabItem.description FROM tabItem WHERE tabItem.is_purchase_item="Yes" AND (IFNULL(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` ="0000-00-00" OR `tabItem`.`end_of_life` > NOW()) AND tabItem.docstatus != 2 AND tabItem.%(key)s LIKE "%s" LIMIT 50' } // Credit To From 063fe503db9a398b2a70fefd05e256144c21617c Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 26 Mar 2012 22:32:34 +0530 Subject: [PATCH 8/8] fix in queries in stock reconciliation --- .../doctype/stock_reconciliation/stock_reconciliation.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py index 08ef1bcac9..86cb099f92 100644 --- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py +++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py @@ -75,7 +75,8 @@ class DocType: def validate_item(self, item, count): """ Validate item exists and non-serialized""" - det = sql("select item_code, has_serial_no from `tabItem` where name = '%s'"% cstr(item), as_dict = 1) + det = sql("select item_code, has_serial_no from `tabItem` \ + where name = %s", cstr(item), as_dict = 1) if not det: msgprint("Item: " + cstr(item) + " mentioned at Row No. " + cstr(count) + "does not exist in the system") self.validated = 0 @@ -88,7 +89,7 @@ class DocType: def validate_warehouse(self, wh, count,): """Validate warehouse exists""" - if not sql("select name from `tabWarehouse` where name = '%s'" % cstr(wh)): + if not sql("select name from `tabWarehouse` where name = %s", cstr(wh)): msgprint("Warehouse: " + cstr(wh) + " mentioned at Row No. " + cstr(count) + " does not exist in the system") self.validated = 0