diff --git a/erpnext/hr/doctype/employee/employee_dashboard.py b/erpnext/hr/doctype/employee/employee_dashboard.py index a4c0af0a4b..a1247d9eb1 100644 --- a/erpnext/hr/doctype/employee/employee_dashboard.py +++ b/erpnext/hr/doctype/employee/employee_dashboard.py @@ -21,7 +21,11 @@ def get_data(): }, { 'label': _('Lifecycle'), - 'items': ['Employee Transfer', 'Employee Promotion', 'Employee Separation', 'Employee Grievance'] + 'items': ['Employee Transfer', 'Employee Promotion', 'Employee Grievance'] + }, + { + 'label': _('Exit'), + 'items': ['Employee Separation', 'Exit Interview', 'Full and Final Statement'] }, { 'label': _('Shift'), diff --git a/erpnext/hr/doctype/exit_interview/exit_interview.py b/erpnext/hr/doctype/exit_interview/exit_interview.py index b2ada4d83c..59dd4631c7 100644 --- a/erpnext/hr/doctype/exit_interview/exit_interview.py +++ b/erpnext/hr/doctype/exit_interview/exit_interview.py @@ -22,7 +22,11 @@ class ExitInterview(Document): title=_('Relieving Date Missing')) def validate_duplicate_interview(self): - doc = frappe.db.exists('Exit Interview', {'employee': self.employee, 'name': ('!=', self.name)}) + doc = frappe.db.exists('Exit Interview', { + 'employee': self.employee, + 'name': ('!=', self.name), + 'docstatus': ('!=', 2) + }) if doc: frappe.throw(_('Exit Interview {0} already scheduled for Employee: {1}').format( get_link_to_form('Exit Interview', doc), frappe.bold(self.employee)), @@ -36,6 +40,18 @@ class ExitInterview(Document): if self.status != 'Completed': frappe.throw(_('Only Completed documents can be submitted')) + self.update_interview_date_in_employee() + + def on_cancel(self): + self.update_interview_date_in_employee() + self.db_set('status', 'Cancelled') + + def update_interview_date_in_employee(self): + if self.docstatus == 1: + frappe.db.set_value('Employee', self.employee, 'held_on', self.date) + elif self.docstatus == 2: + frappe.db.set_value('Employee', self.employee, 'held_on', None) + @frappe.whitelist() def send_exit_questionnaire(interviews):