make quality inspection in query configurable

This commit is contained in:
Zlash65 2018-12-13 13:28:01 +05:30
parent 58a4f0e157
commit 9fde660aaf

View File

@ -61,7 +61,7 @@ def item_query(doctype, txt, searchfield, start, page_len, filters):
if filters.get("from"): if filters.get("from"):
from frappe.desk.reportview import get_match_cond from frappe.desk.reportview import get_match_cond
mcond = get_match_cond(filters["from"]) mcond = get_match_cond(filters["from"])
cond = "" cond, qi_condition = "", "and (quality_inspection is null or quality_inspection = '')"
if filters.get('from') in ['Purchase Invoice Item', 'Purchase Receipt Item']: if filters.get('from') in ['Purchase Invoice Item', 'Purchase Receipt Item']:
cond = """and item_code in (select name from `tabItem` where cond = """and item_code in (select name from `tabItem` where
@ -72,9 +72,13 @@ def item_query(doctype, txt, searchfield, start, page_len, filters):
elif filters.get('from') == 'Stock Entry Detail': elif filters.get('from') == 'Stock Entry Detail':
cond = """and s_warehouse is null""" cond = """and s_warehouse is null"""
if filters.get('from') in ['Supplier Quotation Item']:
qi_condition = ""
return frappe.db.sql(""" select item_code from `tab{doc}` return frappe.db.sql(""" select item_code from `tab{doc}`
where parent=%(parent)s and docstatus < 2 and item_code like %(txt)s where parent=%(parent)s and docstatus < 2 and item_code like %(txt)s
and (quality_inspection is null or quality_inspection = '') {qi_condition} {cond} {mcond}
{cond} {mcond} order by item_code limit {start}, {page_len}""".format(doc=filters.get('from'), order by item_code limit {start}, {page_len}""".format(doc=filters.get('from'),
parent=filters.get('parent'), cond=cond, mcond=mcond, start=start, page_len = page_len), parent=filters.get('parent'), cond = cond, mcond = mcond, start = start,
page_len = page_len, qi_condition = qi_condition),
{'parent': filters.get('parent'), 'txt': "%%%s%%" % txt}) {'parent': filters.get('parent'), 'txt': "%%%s%%" % txt})