fix: tests and sider issues
diff --git a/erpnext/hr/doctype/exit_interview/exit_interview.json b/erpnext/hr/doctype/exit_interview/exit_interview.json
index 86720a1..989a1b8 100644
--- a/erpnext/hr/doctype/exit_interview/exit_interview.json
+++ b/erpnext/hr/doctype/exit_interview/exit_interview.json
@@ -120,8 +120,8 @@
"fieldname": "interviewers",
"fieldtype": "Table MultiSelect",
"label": "Interviewers",
- "options": "Interviewer",
- "reqd": 1
+ "mandatory_depends_on": "eval:doc.status==='Scheduled';",
+ "options": "Interviewer"
},
{
"fetch_from": "employee.date_of_joining",
@@ -218,7 +218,7 @@
"index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [],
- "modified": "2021-12-07 14:08:29.355390",
+ "modified": "2021-12-07 23:39:22.645401",
"modified_by": "Administrator",
"module": "HR",
"name": "Exit Interview",
diff --git a/erpnext/hr/doctype/exit_interview/test_exit_interview.py b/erpnext/hr/doctype/exit_interview/test_exit_interview.py
index 8eeb4a1..b31d593 100644
--- a/erpnext/hr/doctype/exit_interview/test_exit_interview.py
+++ b/erpnext/hr/doctype/exit_interview/test_exit_interview.py
@@ -4,6 +4,7 @@
import unittest
import frappe
+from frappe import _
from frappe.core.doctype.user_permission.test_user_permission import create_user
from frappe.tests.test_webform import create_custom_doctype, create_webform
from frappe.utils import getdate
@@ -13,6 +14,9 @@
class TestExitInterview(unittest.TestCase):
+ def setUp(self):
+ frappe.db.sql('delete from `tabExit Interview`')
+
def test_duplicate_interview(self):
employee = make_employee('employeeexit1@example.com')
frappe.db.set_value('Employee', employee, 'relieving_date', getdate())
@@ -23,6 +27,8 @@
def test_relieving_date_validation(self):
employee = make_employee('employeeexit2@example.com')
+ # unset relieving date
+ frappe.db.set_value('Employee', employee, 'relieving_date', None)
interview = create_exit_interview(employee, save=False)
self.assertRaises(frappe.ValidationError, interview.save)
@@ -52,9 +58,13 @@
def test_send_exit_questionnaire(self):
create_custom_doctype()
create_webform()
+ template = create_notification_template()
webform = frappe.db.get_all('Web Form', limit=1)
- frappe.db.set_value('HR Settings', 'HR Settings', 'exit_questionnaire_web_form', webform[0].name)
+ frappe.db.set_value('HR Settings', 'HR Settings', {
+ 'exit_questionnaire_web_form': webform[0].name,
+ 'exit_questionnaire_notification_template': template
+ })
employee = make_employee('employeeexit3@example.com')
frappe.db.set_value('Employee', employee, 'relieving_date', getdate())
@@ -87,3 +97,21 @@
if save:
return doc.insert()
return doc
+
+
+def create_notification_template():
+ template = frappe.db.exists('Email Template', _('Exit Questionnaire Notification'))
+ if not template:
+ base_path = frappe.get_app_path('erpnext', 'hr', 'doctype')
+ response = frappe.read_file(os.path.join(base_path, 'exit_interview/exit_questionnaire_notification_template.html'))
+
+ template = frappe.get_doc({
+ 'doctype': 'Email Template',
+ 'name': _('Exit Questionnaire Notification'),
+ 'response': response,
+ 'subject': _('Exit Questionnaire Notification'),
+ 'owner': frappe.session.user,
+ }).insert(ignore_permissions=True)
+ template = template.name
+
+ return template
\ No newline at end of file
diff --git a/erpnext/hr/report/employee_exits/test_employee_exits.py b/erpnext/hr/report/employee_exits/test_employee_exits.py
index 1c64b46..d7e95a6 100644
--- a/erpnext/hr/report/employee_exits/test_employee_exits.py
+++ b/erpnext/hr/report/employee_exits/test_employee_exits.py
@@ -5,13 +5,16 @@
from erpnext.hr.doctype.employee.test_employee import make_employee
from erpnext.hr.doctype.exit_interview.test_exit_interview import create_exit_interview
-from erpnext.hr.doctype.full_and_final_statement.test_full_and_final_statement import create_full_and_final_statement
+from erpnext.hr.doctype.full_and_final_statement.test_full_and_final_statement import (
+ create_full_and_final_statement,
+)
from erpnext.hr.report.employee_exits.employee_exits import execute
class TestEmployeeExits(unittest.TestCase):
@classmethod
def setUpClass(cls):
+ create_company()
frappe.db.sql("delete from `tabEmployee` where company='Test Company'")
frappe.db.sql("delete from `tabFull and Final Statement` where company='Test Company'")
frappe.db.sql("delete from `tabExit Interview` where company='Test Company'")
@@ -24,26 +27,30 @@
@classmethod
def create_records(cls):
- cls.emp1 = make_employee('employeeexit1@example.com',
+ cls.emp1 = make_employee(
+ 'employeeexit1@example.com',
company='Test Company',
date_of_joining=getdate('01-10-2021'),
relieving_date=add_days(getdate(), 14),
designation='Accountant'
)
- cls.emp2 = make_employee('employeeexit2@example.com',
+ cls.emp2 = make_employee(
+ 'employeeexit2@example.com',
company='Test Company',
date_of_joining=getdate('01-12-2021'),
relieving_date=add_days(getdate(), 15),
designation='Accountant'
)
- cls.emp3 = make_employee('employeeexit3@example.com',
+ cls.emp3 = make_employee(
+ 'employeeexit3@example.com',
company='Test Company',
date_of_joining=getdate('02-12-2021'),
relieving_date=add_days(getdate(), 29),
designation='Engineer'
)
- cls.emp4 = make_employee('employeeexit4@example.com',
+ cls.emp4 = make_employee(
+ 'employeeexit4@example.com',
company='Test Company',
date_of_joining=getdate('01-12-2021'),
relieving_date=add_days(getdate(), 30),
@@ -90,34 +97,36 @@
employee1 = frappe.get_doc('Employee', self.emp1)
employee2 = frappe.get_doc('Employee', self.emp2)
- expected_data = [{
- 'employee': employee1.name,
- 'employee_name': employee1.employee_name,
- 'date_of_joining': employee1.date_of_joining,
- 'relieving_date': employee1.relieving_date,
- 'department': employee1.department,
- 'designation': employee1.designation,
- 'reports_to': None,
- 'exit_interview': self.interview1.name,
- 'interview_status': self.interview1.status,
- 'employee_status': '',
- 'questionnaire': employee1.name,
- 'full_and_final_statement': self.fnf1.name
- },
- {
- 'employee': employee2.name,
- 'employee_name': employee2.employee_name,
- 'date_of_joining': employee2.date_of_joining,
- 'relieving_date': employee2.relieving_date,
- 'department': employee2.department,
- 'designation': employee2.designation,
- 'reports_to': None,
- 'exit_interview': self.interview2.name,
- 'interview_status': self.interview2.status,
- 'employee_status': '',
- 'questionnaire': employee2.name,
- 'full_and_final_statement': self.fnf2.name
- }]
+ expected_data = [
+ {
+ 'employee': employee1.name,
+ 'employee_name': employee1.employee_name,
+ 'date_of_joining': employee1.date_of_joining,
+ 'relieving_date': employee1.relieving_date,
+ 'department': employee1.department,
+ 'designation': employee1.designation,
+ 'reports_to': None,
+ 'exit_interview': self.interview1.name,
+ 'interview_status': self.interview1.status,
+ 'employee_status': '',
+ 'questionnaire': employee1.name,
+ 'full_and_final_statement': self.fnf1.name
+ },
+ {
+ 'employee': employee2.name,
+ 'employee_name': employee2.employee_name,
+ 'date_of_joining': employee2.date_of_joining,
+ 'relieving_date': employee2.relieving_date,
+ 'department': employee2.department,
+ 'designation': employee2.designation,
+ 'reports_to': None,
+ 'exit_interview': self.interview2.name,
+ 'interview_status': self.interview2.status,
+ 'employee_status': '',
+ 'questionnaire': employee2.name,
+ 'full_and_final_statement': self.fnf2.name
+ }
+ ]
self.assertEqual(expected_data, report[1]) # rows
@@ -189,33 +198,45 @@
employee3 = frappe.get_doc('Employee', self.emp3)
employee4 = frappe.get_doc('Employee', self.emp4)
- expected_data = [{
- 'employee': employee3.name,
- 'employee_name': employee3.employee_name,
- 'date_of_joining': employee3.date_of_joining,
- 'relieving_date': employee3.relieving_date,
- 'department': employee3.department,
- 'designation': employee3.designation,
- 'reports_to': None,
- 'exit_interview': self.interview3.name,
- 'interview_status': self.interview3.status,
- 'employee_status': '',
- 'questionnaire': employee3.name,
- 'full_and_final_statement': None
- },
- {
- 'employee': employee4.name,
- 'employee_name': employee4.employee_name,
- 'date_of_joining': employee4.date_of_joining,
- 'relieving_date': employee4.relieving_date,
- 'department': employee4.department,
- 'designation': employee4.designation,
- 'reports_to': None,
- 'exit_interview': None,
- 'interview_status': None,
- 'employee_status': None,
- 'questionnaire': None,
- 'full_and_final_statement': None
- }]
+ expected_data = [
+ {
+ 'employee': employee3.name,
+ 'employee_name': employee3.employee_name,
+ 'date_of_joining': employee3.date_of_joining,
+ 'relieving_date': employee3.relieving_date,
+ 'department': employee3.department,
+ 'designation': employee3.designation,
+ 'reports_to': None,
+ 'exit_interview': self.interview3.name,
+ 'interview_status': self.interview3.status,
+ 'employee_status': '',
+ 'questionnaire': employee3.name,
+ 'full_and_final_statement': None
+ },
+ {
+ 'employee': employee4.name,
+ 'employee_name': employee4.employee_name,
+ 'date_of_joining': employee4.date_of_joining,
+ 'relieving_date': employee4.relieving_date,
+ 'department': employee4.department,
+ 'designation': employee4.designation,
+ 'reports_to': None,
+ 'exit_interview': None,
+ 'interview_status': None,
+ 'employee_status': None,
+ 'questionnaire': None,
+ 'full_and_final_statement': None
+ }
+ ]
- self.assertEqual(expected_data, report[1]) # rows
\ No newline at end of file
+ self.assertEqual(expected_data, report[1]) # rows
+
+
+def create_company():
+ if not frappe.db.exists('Company', 'Test Company'):
+ frappe.get_doc({
+ 'doctype': 'Company',
+ 'company_name': 'Test Company',
+ 'default_currency': 'INR',
+ 'country': 'India'
+ }).insert()
\ No newline at end of file