fix(employee): show only active employees in the error display while marking a reporting to employee as left

This commit is contained in:
Diksha 2019-11-11 19:22:51 +05:30
parent 001ee5ee1b
commit 39152f935c

View File

@ -167,10 +167,11 @@ class Employee(NestedSet):
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: