brotherton-erpnext/erpnext/docs/user/manual/en/customize-erpnext/custom-scripts/custom-script-examples/restrict-cancel-rights.md

20 lines
576 B
Markdown
Raw Normal View History

2017-07-31 10:50:43 +00:00
# Restrict Cancel Rights
2015-11-05 11:25:10 +00:00
Add a handler to `custom_before_cancel` event:
cur_frm.cscript.custom_before_cancel = function(doc) {
if (frappe.user_roles.indexOf("Accounts User")!=-1 && frappe.user_roles.indexOf("Accounts Manager")==-1
2015-11-05 11:25:10 +00:00
&& user_roles.indexOf("System Manager")==-1) {
if (flt(doc.grand_total) > 10000) {
frappe.msgprint("You can not cancel this transaction, because grand total \
2015-11-05 11:25:10 +00:00
is greater than 10000");
frappe.validated = false;
2015-11-05 11:25:10 +00:00
}
}
}
{next}