How do we create our controllers functions as in erpnext.controllers.queries…
I need to set a query in a child table (PO Item form). I’m doing this with a set_query function with the query to be set in a python function. In erpnext, this is achieved through the controllers module.
How do I achieve a similar controllers function for my custom app? As a dumb, I created controllers folder in my custom app, and added my query inside queries.py. When i try to call that through set_query function, I get the error 'App Controllers not instaled".
Here is my js code to set the query in Item Code field in Purchase Order Item form -
me.frm.set_query(“item_code”, “items”, function(doc, cdt, cdn) {
return { query: “myapp.controllers.queries.supplier_items_query” }
});
And this is the actual query -
def supplier_items_query(doctype, txt, searchfield, start, page_len, filters):
return frappe.db.sql(“”“select parent from tabItem Supplier
where supplier = ‘S1’
and docstatus < 2"”")
Any ideas how to achieve this in custom app? If I put this query under erpnext.controllers.queries file, it works fine. But I dont want to edit the erpnext file, and want to have this function in my custom app.