Hi,
I created a server side script for item_query_for_so but the issue is it is not being filtered as and when I type in the text box:
def item_query_for_so(doctype, txt, searchfield, start, page_len, filters, as_dict=False):
conditions = []
return frappe.db.sql("""select tabItem.name,
marketing_name as item_name
from `tabItem`
where tabItem.docstatus < 2
and tabItem.has_variants=0
and tabItem.disabled=0
{fcond} {mcond}
order by
marketing_number
limit %(start)s, %(page_len)s """.format(
key=searchfield,
fcond=get_filters_cond(doctype, filters, conditions).replace('%', '%%'),
mcond=get_match_cond(doctype).replace('%', '%%')),
{
"today": nowdate(),
"txt": "%%%s%%" % txt,
"_txt": txt.replace("%", ""),
"start": start,
"page_len": page_len
}, as_dict=as_dict)
My Custom Script:
cur_frm.set_query("item_code", "shipping_lists", function (doc, cdt, cdn)
{
var d= locals[cdt][cdn];
return {
query: "library.update_items.item_query_for_so",
searchfield: "marketing_name",
"filters": [
['Item','workflow_state','=', "Approved"],
['Item','marketing_name','!=',null],
['Item','marketing_name','!=',""],
]
}
}); // end of set_query
Not Filtering the Data:
Edit: Any idea what could be the issue?
Regards
Ruchin Sharma