added anti-delete to standart groups

This commit is contained in:
Ali 2025-08-14 16:07:29 +04:00
parent 9f3ff8598b
commit bbb45e004b
3 changed files with 38 additions and 1 deletions

View File

@ -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>
# ------------------ # ------------------

6
taxes_az/item_group.py Normal file
View File

@ -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"))

View File

@ -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();
}
}
});