Desired Feature: Would like the ability to restrict the purchase of items to only suppliers approved for each item.
Pic displaying list of supplier approved for each item
You can see here in the pic below that one can pic any vendor from which to purchase a hard drive. in this case Jans Pet Supply.
We can tackle this problem in qty 2 ways
1 Filter items based on supplier
Hi @bghayad ! Yes this is possible. Is your ERPNext self hosted? If it is, you may want to use something like this:
JS:
me.frm.set_query("item_code", "items", function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
return {
query: "app_name.def_name_here",
filters:{
'supplier': doc.supplier
}
}
});
Python Script:
def name_here(doctype, txt, searchfield, start, page_len, filters):
return frappe.db.sql("""Select item_code from `tabItem` where default_supplier = %s""", (filters.ge…
2 Create a custom script to validate suppliers based on the list of suppliers listed for item.
How to make validation on client side?
I already have my own code.
It appears the msgprint but it still go to saving the document.
Here my code:
frappe.ui.form.on("General Receipt", "validate", function(frm) {
if (frm.doc.status === "Received In") {
if (frm.doc.total_need_to_pay < frm.doc.payment) {
validate = false;
msgprint("<b>Payment</b> is more than <b>total need to pay.</b>");
}
}
if (frm.doc.date < get_today()) {
msgprint("You can not select past date in <b>…