fix(employee): show only active employees in the error display while marking a reporting to employee as left
diff --git a/erpnext/hr/doctype/employee/employee.py b/erpnext/hr/doctype/employee/employee.py
index 3fc330e..703ec06 100755
--- a/erpnext/hr/doctype/employee/employee.py
+++ b/erpnext/hr/doctype/employee/employee.py
@@ -167,10 +167,11 @@
def validate_status(self):
if self.status == 'Left':
reports_to = frappe.db.get_all('Employee',
- filters={'reports_to': self.name}
+ filters={'reports_to': self.name, 'status': "Active"},
+ fields=['name','employee_name']
)
if reports_to:
- link_to_employees = [frappe.utils.get_link_to_form('Employee', employee.name) for employee in 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)
if not self.relieving_date: