diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py index a1d9a5b00d..2460a26de4 100644 --- a/erpnext/controllers/stock_controller.py +++ b/erpnext/controllers/stock_controller.py @@ -166,21 +166,19 @@ class StockController(AccountsController): def get_future_stock_vouchers(self): - future_stock_vouchers = [] - - if hasattr(self, "fname"): + condition = "" + item_list = [] + if getattr(self, "fname", None): item_list = [d.item_code for d in self.get(self.fname)] - condition = ''.join(['and item_code in (\'', '\', \''.join(item_list) ,'\')']) - else: - condition = "" + if item_list: + condition = "and item_code in ({})".format(", ".join(["%s"] * len(item_list))) - for d in frappe.db.sql("""select distinct sle.voucher_type, sle.voucher_no + future_stock_vouchers = frappe.db.sql("""select distinct sle.voucher_type, sle.voucher_no from `tabStock Ledger Entry` sle - where timestamp(sle.posting_date, sle.posting_time) >= timestamp(%s, %s) %s - order by timestamp(sle.posting_date, sle.posting_time) asc, name asc""" % - ('%s', '%s', condition), (self.posting_date, self.posting_time), - as_dict=True): - future_stock_vouchers.append([d.voucher_type, d.voucher_no]) + where timestamp(sle.posting_date, sle.posting_time) >= timestamp(%s, %s) {condition} + order by timestamp(sle.posting_date, sle.posting_time) asc, name asc""".format( + condition=condition), tuple([self.posting_date, self.posting_date] + item_list), + as_list=True) return future_stock_vouchers diff --git a/erpnext/setup/doctype/customer_group/customer_group.js b/erpnext/setup/doctype/customer_group/customer_group.js index 03c5c2bfdf..2e8cd7e6c4 100644 --- a/erpnext/setup/doctype/customer_group/customer_group.js +++ b/erpnext/setup/doctype/customer_group/customer_group.js @@ -19,8 +19,7 @@ cur_frm.cscript.set_root_readonly = function(doc) { //get query select Customer Group cur_frm.fields_dict['parent_customer_group'].get_query = function(doc,cdt,cdn) { - return{ - searchfield:['name', 'parent_customer_group'], + return { filters: { 'is_group': "Yes" }