Merge pull request #19549 from DeeMysterio/v12-emp-err

fix(employee): show only active employees in the error display while …
This commit is contained in:
Deepesh Garg 2019-11-11 21:50:07 +05:30 committed by GitHub
commit 2689acfc8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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: