skip abbr, reload doc, disable edit for root department node'
diff --git a/erpnext/hr/doctype/department/department.js b/erpnext/hr/doctype/department/department.js
index 71cf2d2..a945312 100644
--- a/erpnext/hr/doctype/department/department.js
+++ b/erpnext/hr/doctype/department/department.js
@@ -2,7 +2,16 @@
// For license information, please see license.txt
frappe.ui.form.on('Department', {
- onload: function(frm) {
-
+ refresh: function(frm) {
+ // read-only for root department
+ if(!frm.doc.parent_department) {
+ cur_frm.set_read_only();
+ cur_frm.set_intro(__("This is a root customer group and cannot be edited."));
+ }
+ },
+ validate: function(frm) {
+ if(frm.doc.name=="All Departments") {
+ frappe.throw(__("You cannot edit root node."));
+ }
}
});
diff --git a/erpnext/hr/doctype/department/department.py b/erpnext/hr/doctype/department/department.py
index 19994ae..6544390 100644
--- a/erpnext/hr/doctype/department/department.py
+++ b/erpnext/hr/doctype/department/department.py
@@ -11,8 +11,11 @@
nsm_parent_field = 'parent_department'
def autoname(self):
- abbr = frappe.db.get_value('Company', self.company, 'abbr')
- self.name = '{0} - {1}'.format(self.department_name, abbr)
+ if not self.department_name=="All Departments":
+ abbr = frappe.db.get_value('Company', self.company, 'abbr')
+ self.name = '{0} - {1}'.format(self.department_name, abbr)
+ else:
+ self.name = self.department_name
def update_nsm_model(self):
frappe.utils.nestedset.update_nsm(self)
diff --git a/erpnext/patches/v11_0/create_department_records_for_each_company.py b/erpnext/patches/v11_0/create_department_records_for_each_company.py
index 4cfe960..6f869b0 100644
--- a/erpnext/patches/v11_0/create_department_records_for_each_company.py
+++ b/erpnext/patches/v11_0/create_department_records_for_each_company.py
@@ -2,7 +2,7 @@
from frappe.utils.nestedset import rebuild_tree
def execute():
- for doctype in ['department', 'leave_period', 'staffing_plan']:
+ for doctype in ['department', 'leave_period', 'staffing_plan', 'job_opening']:
frappe.reload_doc("hr", "doctype", doctype)
companies = frappe.db.get_all("Company", fields=["name", "abbr"])