added anti-delete to standart groups
This commit is contained in:
parent
9f3ff8598b
commit
bbb45e004b
|
|
@ -42,9 +42,15 @@ doctype_js = {
|
||||||
"public/js/xml_mapping/mapping_storage.js",
|
"public/js/xml_mapping/mapping_storage.js",
|
||||||
"public/js/xml_mapping/xml_generator.js"
|
"public/js/xml_mapping/xml_generator.js"
|
||||||
],
|
],
|
||||||
"Company": "client/company.js"
|
"Company": "client/company.js",
|
||||||
|
"Item Group": "public/js/item_group.js"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
doc_events = {
|
||||||
|
"Item Group": {
|
||||||
|
"on_trash": "taxes_az.item_group.validate_item_group_deletion"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Includes in <head>
|
# Includes in <head>
|
||||||
# ------------------
|
# ------------------
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
import frappe
|
||||||
|
from frappe import _
|
||||||
|
|
||||||
|
def validate_item_group_deletion(doc, method):
|
||||||
|
if doc.is_standard:
|
||||||
|
frappe.throw(_("Cannot delete standard Item Group"))
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
frappe.ui.form.on('Item Group', {
|
||||||
|
refresh: function(frm) {
|
||||||
|
if (frm.doc.is_standard) {
|
||||||
|
frm.set_intro(__("This is a root item group and cannot be edited."), true);
|
||||||
|
frm.disable_form();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
onload: function(frm) {
|
||||||
|
if (frm.doc.is_standard) {
|
||||||
|
frm.set_intro(__("This is a root item group and cannot be edited."), true);
|
||||||
|
frm.disable_form();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
is_standard: function(frm) {
|
||||||
|
if (frm.doc.is_standard) {
|
||||||
|
frm.set_intro(__("This is a root item group and cannot be edited."), true);
|
||||||
|
frm.disable_form();
|
||||||
|
} else {
|
||||||
|
frm.set_intro('');
|
||||||
|
frm.enable_form();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue