Try ERPNext Buy Support Partners Foundation

How to prevent submission of sales order if order qty is less than actual qty through custom script?

How to prevent submission in sales order if order qty is less than actual qty through custom script?

Hi Mark,

Does not ERPNext have this control already built in? Is there a specific need for you to use custom scripts to achieve this?

You may have set the over delivery percentage at the global level or at an item level and that could be the reason for your question.

Hope this helps.

Thanks

Jay

1 Like

Thanks, Jay I have made a custom script to control it.

Thanks for the advise.

@markgates

would be great if you can share the script here. It’ll help others also who’re looking for something similar.

here is the script

frappe.ui.form.on('Sales Order', {
	before_save: (frm) => {
	   var table = cur_frm.doc.items
	   for(var i in table ) {
	       if(table[i].qty >= table[i].actual_qty) {
	           var msg = `Please reduce the qty for item ${table[i].item_code}`
	           frappe.throw(msg)
	       }
	   }
	}
})
1 Like