How to make Notification Massage about Stock Shortage to user when submitted Sales Order
You need to create a custom script in Sales Order
for on_submit
and display a message using frappe.msgprint
if stock shortage.
Dear @JoEz
Thanks for your response could you please check this script
frappe.ui.form.on("Sales Order Item", {
onsubmit: function(frm) {
if(frm.doc.projected_qty < 0){
frappe.msgprint('Warning');
}
}
})
Not sure if it is onsubmit or on_submit …check both …it doesn’t work for child tables …if you need it for Sales Order Item the script is different; have a look in the forum for hints …search for “child table”
i’m confusing about what you mean about child table hint i need to know how this can solve the problem
Hello,
Try following script, it is working
frappe.ui.form.on("Sales Order Item", "item_code", function(frm, cdt, cdn){
frappe.after_ajax(function() {
var d = locals[cdt][cdn];
if(d.projected_qty<=0){
frappe.msgprint("Projected Qty is <=0");
}
});
});
This code should put under Sales Order typeio
Probably he needs on_nubmit …so need to check each item in doc
Dears Thanks for your response
First the above script only print the message not check the condition
second actually i need the script check the qty put by user and the actual qty and if the actual qty not covered the qty prevent user for save the order
Dears This script is working
frappe.ui.form.on("Sales Order Item", "qty", function(frm, cdt, cdn){
frappe.after_ajax(function() {
var d = locals[cdt][cdn];
if(d.actual_qty < d.qty){
frappe.msgprint("Warning");
}
});
});
But only warning message not prevent user to save the document:thinking:
any suggesting
You have to check qty when validating document, kind of:
frappe.ui.form.on("Sales Order", "validate", function(frm, cdt, cdn){
frappe.after_ajax(function() {
$.each(from.doc.items, function(d, i){
if (d.actual_qty < d.qty)
frappe.throw("Warning");
}
});
});
Guy fix it …now you have the direction …
hello
Where can I put this code?
thanks in advance.
Custom script