Hi,
I want to disable “Create” button on “Sales Order” form for certain condition. I am using the following code:
frappe.ui.form.on('Sales Order', {
refresh: function(frm)
{ if (frm.doc.project)
setTimeout(() => {
frm.remove_custom_button('Update Items');
frm.remove_custom_button('Create');
frm.remove_custom_button('Close', 'Status');
}, 10);
}
}) ;
“Update Items” button is disabled. But “Create” button is not. Is anything wrong with the above script?
Thanks,
Joseph
NCP
2
Hi @pjoseph,
Please check it.
Please apply it.
frappe.ui.form.on('Sales Order', {
refresh: function(frm) {
setTimeout(() => {
frm.remove_custom_button('Sales Invoice', 'Create');
frm.remove_custom_button('Purchase Order', 'Create');
frm.remove_custom_button('Subscription', 'Create');
frm.remove_custom_button('Payment Request', 'Create');
frm.remove_custom_button('Payment', 'Create');
}, 10);
}
});
Thank You!
Super !!! It works Good !!! Thanks Patel @NCP
We have to remove all the options under the “Button”, then the main button disappears.
refresh: function(frm)
{ if (frm.doc.project)
setTimeout(() => {
frm.remove_custom_button('Work Order', 'Create');
frm.remove_custom_button('Pick List', 'Create');
frm.remove_custom_button('Sales Invoice', 'Create');
frm.remove_custom_button('Purchase Order', 'Create');
frm.remove_custom_button('Subscription', 'Create');
frm.remove_custom_button('Payment Request', 'Create');
frm.remove_custom_button('Payment', 'Create');
frm.remove_custom_button('Delivery Note', 'Create');
frm.remove_custom_button('Material Request','Create');
frm.remove_custom_button('Project', 'Create');
frm.remove_custom_button('Request for Raw Materials', 'Create');
}, 10);
},