fix: Hide Ex-Employees from Employee Tree and minor message UX (#23711)
* fix: Hide Ex-Employees from Employee Tree and minor message UX
* fix: translation syntax
diff --git a/erpnext/hr/doctype/employee/employee.py b/erpnext/hr/doctype/employee/employee.py
index 85eaa5e..dfc600c 100755
--- a/erpnext/hr/doctype/employee/employee.py
+++ b/erpnext/hr/doctype/employee/employee.py
@@ -56,7 +56,7 @@
if existing_user_id:
remove_user_permission(
"Employee", self.name, existing_user_id)
-
+
def after_rename(self, old, new, merge):
self.db_set("employee", new)
@@ -181,8 +181,11 @@
)
if reports_to:
link_to_employees = [frappe.utils.get_link_to_form('Employee', employee.name, label=employee.employee_name) for employee in reports_to]
- throw(_("Employee status cannot be set to 'Left' as following employees are currently reporting to this employee: ")
- + ', '.join(link_to_employees), EmployeeLeftValidationError)
+ message = _("The following employees are currently still reporting to {0}:").format(frappe.bold(self.employee_name))
+ message += "<br><br><ul><li>" + "</li><li>".join(link_to_employees)
+ message += "</li></ul><br>"
+ message += _("Please make sure the employees above report to another Active employee.")
+ throw(message, EmployeeLeftValidationError, _("Cannot Relieve Employee"))
if not self.relieving_date:
throw(_("Please enter relieving date."))
@@ -215,7 +218,7 @@
def validate_preferred_email(self):
if self.prefered_contact_email and not self.get(scrub(self.prefered_contact_email)):
- frappe.msgprint(_("Please enter " + self.prefered_contact_email))
+ frappe.msgprint(_("Please enter {0}").format(self.prefered_contact_email))
def validate_onboarding_process(self):
employee_onboarding = frappe.get_all("Employee Onboarding",
@@ -417,9 +420,9 @@
@frappe.whitelist()
def get_children(doctype, parent=None, company=None, is_root=False, is_tree=False):
- filters = []
+ filters = [['status', '!=', 'Left']]
if company and company != 'All Companies':
- filters = [['company', '=', company]]
+ filters.append(['company', '=', company])
fields = ['name as value', 'employee_name as title']