From 9fbed5617f95d8306fbbebd111c3d0cd850f4305 Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Fri, 12 Jan 2018 16:22:33 +0530 Subject: [PATCH] [Fix] Wrong batch showing in the popup (#12421) --- erpnext/accounts/doctype/pos_profile/pos_profile.py | 2 +- erpnext/controllers/queries.py | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/erpnext/accounts/doctype/pos_profile/pos_profile.py b/erpnext/accounts/doctype/pos_profile/pos_profile.py index 846d79d610f..0bce49c016e 100644 --- a/erpnext/accounts/doctype/pos_profile/pos_profile.py +++ b/erpnext/accounts/doctype/pos_profile/pos_profile.py @@ -25,7 +25,7 @@ class POSProfile(Document): `tabPOS Profile User` pfu, `tabPOS Profile` pf where pf.name = pfu.parent and pfu.user = %s and pf.name != %s and pf.company = %s - and pfu.default=1""", (row.user, self.name, self.company)) + and pfu.default=1 and pf.disabled = 0""", (row.user, self.name, self.company)) if row.default and res: msgprint(_("Already set default in pos profile {0} for user {1}, kindly disabled default") diff --git a/erpnext/controllers/queries.py b/erpnext/controllers/queries.py index a71a08e7fca..cd74fb5717f 100644 --- a/erpnext/controllers/queries.py +++ b/erpnext/controllers/queries.py @@ -414,10 +414,11 @@ def get_doctype_wise_filters(filters): @frappe.whitelist() def get_batch_numbers(doctype, txt, searchfield, start, page_len, filters): - query = 'select batch_id from `tabBatch` ' \ - 'where (`tabBatch`.expiry_date >= CURDATE() or `tabBatch`.expiry_date IS NULL)' + query = """select batch_id from `tabBatch` + where (expiry_date >= CURDATE() or expiry_date IS NULL) + and name like '{txt}'""".format(txt = frappe.db.escape('%{0}%'.format(txt))) - if filters and filters.get('item_code'): - query += 'where item = %(item_code)s' % filters + if filters and filters.get('item'): + query += " and item = '{item}'".format(item = frappe.db.escape(filters.get('item'))) return frappe.db.sql(query)