How to restrict supplier field on Purchase Order screen to certain values based on filter

@rmehta
I have managed to get it to work by changing onload to refresh. What is the difference between the two?

frappe.ui.form.on("Purchase Order", "refresh", function(frm) {
    cur_frm.set_query("supplier", function() {
        return {
            "filters": {
                "currency_pay_in": "USD"
            }
        };
    });
});
3 Likes