Hi,
I want to filter the Item Group in Request Site Expense Item depending on the child table in the selected Customer Agreement child table included Item Group
Customer Contract
I want to show the item group that I saved in Estimate Item CC child table in Customer Contract
avc
October 9, 2023, 7:52am
4
1 Like
Thank you @avc , it’s good resource but it’s not explain how can pass parameter from js to python file (query) as shown in example
This is my code
doctype.js
refresh:function(frm){
frm.set_query('item_group', 'request_site_expense_items', function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
return {
query: "construction.construction.doctype.request_site_expense.request_site_expense.get_item_group",
filters: {
'customer_contract': frm.doc.customer_contract
}
};
});
};
Python file
@frappe.whitelist()
def get_item_group(doctype, txt, searchfield, start, page_len, filters):
frappe.msgprint(str(filters))
return frappe.db.sql("""
SELECT
ig.name
FROM
`tabItem Group` ig
INNER JOIN
`tabEstimate Item CC` icc on ig.name = icc.item_group
INNER JOIN
`tabCustomer Agreement` ca on ca.name = icc.parent
INNER JOIN
`tabWorker Agreement` wa on ca.name = wa.contract
INNER JOIN
`tabWorker Agreement Items` wai on wai.parent = wa.name
and wai.item_group = icc.item_group
WHERE
ca.party_one like %s
""", ("%" + txt + "%"))
I need to pass customer_contract to compare it with
ca.party_one = customer_contract
Hello Omar . I want to ask you if you can help me with a problem similar to yours, which is that I want to filter the options based on the section name.