ERPNext Conference 2019* ERPNext.com Blog

Update stock bug in the sales invoice


#1

I have customize the sales invoice update stock check box as mandatory to avoid being not selecting by users and course stock updating problem.

But user can submit sales invoice without click on update stock even I customize this click box as mandatory.

Where do I miss?


#2

Hey tried this with not with a sales invoice but with a different form. I too was able to submit it without setting a check mark I made mandatory

Meanwhile you can use a custom script on event validate, if the Update Stock check mark is not 1 you throw an exception and prevent it from submission


#3

How to do that?


#4

Try this

frappe.ui.form.on("Sales Invoice",{
    validate: function(frm){
         if(!cur_frm.doc.update_stock){
                frappe.throw("Update Stock is unchecked")
         }
    }
})

Check if that field is called update_stock or something else. Just replace it by the correct field name


#5

Why is not coming as default in ERP next?


#6

earlier It was works fine.


#7

Make the ‘Update Stock’ field read only and set the Default value to 1.