Hello all,
Just started coding with ERPNext. Very nice product. I’ve added a custom script to filter the items in a dropdown on a doctype to include only specific items from a linked doctype. This works fine with a single filter:
frappe.ui.form.on("Truck Setup", "refresh", function(frm) {
cur_frm.set_query("driver", function() {
return {
"filters": {
"designation": "Truck Driver"
}
};
});
});
As you can see designation will only take items with designation “Truck Driver” from the HR Module. How can I filter based on 2 options such as “Truck Driver” and “Vehicle Driver”
Is there any “OR” clause ?
this should help
filters: {
"designation" : ["in", "Truck Driver, Vehicle Driver"]
}
References:
company: cur_frm.doc.company
}
})
}, __("Get items from"));
cur_frm.add_custom_button(__('Warranty Claim'),
function() {
erpnext.utils.map_current_doc({
method: "erpnext.support.doctype.warranty_claim.warranty_claim.make_maintenance_visit",
source_doctype: "Warranty Claim",
get_query_filters: {
status: ["in", "Open, Work in Progress"],
customer: cur_frm.doc.customer || undefined,
company: cur_frm.doc.company
}
})
}, __("Get items from"));
cur_frm.add_custom_button(__('Sales Order'),
function() {
erpnext.utils.map_current_doc({
method: "erpnext.selling.doctype.sales_order.sales_order.make_maintenance_visit",
source_doctype: "Sales Order",
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
frappe.ui.form.on('Mode of Payment', {
setup: function(frm) {
frm.set_query("default_account", "accounts", function(doc, cdt, cdn) {
let d = locals[cdt][cdn];
return {
filters: [
['Account', 'account_type', 'in', 'Bank, Cash, Receivable'],
['Account', 'is_group', '=', 0],
['Account', 'company', '=', d.company]
]
};
});
},
});
2 Likes