I would like to validate the rate in a purchase order according to this condition:
Show an error if the item it’s not included in the price list of the supplier.
Here is some pseudocode (It should look something like this in my script based on the date validation script example)
frappe.ui.form.on("Purchase Order", "validate", function(frm) {
if (frm.doc.rate in list_price) {
msgprint(__("The item has no list price for this supplier"));
throw "no rate"
}
});
What is the variable that references the rate?
What is the variable that reference the list price?
Hi @Javier_Cardenas ,
rate
price_list_rate
you can find the variable/fieldname in Customize Form
under Purchase Order Item
doctype.
If you wish to perform these checks on Purchase Order’s validate
event then, you will need to iterate through the Purchase Order Item
documents. please find the below example
frappe.ui.form.on("Purchase Order", "validate", function(frm){
$.each(frm.doc.items, function(idx, item){
// code to validate item.rate and item.price_list_rate
});
})
Thanks, Makarand
Thank you,
This was my solution.
frappe.ui.form.on("Purchase Order", "validate", function(frm){
$.each(frm.doc.items, function(idx, item){
if(item.price_list_rate == 0) {
msgprint(__("El item " + item.item_name + " no tiene precio"));
validated = false;
}
});
})
1 Like