Skip to content

Commit

Permalink
fix: Employee Onboarding and Separation UX (backport #29504) (#29505)
Browse files Browse the repository at this point in the history
Co-authored-by: Rucha Mahabal <ruchamahabal2@gmail.com>
  • Loading branch information
mergify[bot] and ruchamahabal authored Jan 29, 2022
1 parent 388293d commit 4a09dc4
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 18 deletions.
8 changes: 6 additions & 2 deletions erpnext/controllers/employee_boarding_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,17 @@ def assign_task_to_users(self, task, users):

def on_cancel(self):
# delete task project
for task in frappe.get_all('Task', filters={'project': self.project}):
project = self.project
for task in frappe.get_all('Task', filters={'project': project}):
frappe.delete_doc('Task', task.name, force=1)
frappe.delete_doc('Project', self.project, force=1)
frappe.delete_doc('Project', project, force=1)
self.db_set('project', '')
for activity in self.activities:
activity.db_set('task', '')

frappe.msgprint(_('Linked Project {} and Tasks deleted.').format(
project), alert=True, indicator='blue')


@frappe.whitelist()
def get_onboarding_details(parent, parenttype):
Expand Down
2 changes: 1 addition & 1 deletion erpnext/hr/doctype/employee/employee_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def get_data():
},
{
'label': _('Lifecycle'),
'items': ['Employee Transfer', 'Employee Promotion', 'Employee Grievance']
'items': ['Employee Onboarding', 'Employee Transfer', 'Employee Promotion', 'Employee Grievance']
},
{
'label': _('Exit'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
},
{
"default": "0",
"depends_on": "eval:['Employee Onboarding', 'Employee Onboarding Template'].includes(doc.parenttype)",
"description": "Applicable in the case of Employee Onboarding",
"fieldname": "required_for_employee_creation",
"fieldtype": "Check",
Expand Down Expand Up @@ -93,7 +94,7 @@
],
"istable": 1,
"links": [],
"modified": "2021-07-30 15:55:22.470102",
"modified": "2022-01-29 14:05:00.543122",
"modified_by": "Administrator",
"module": "HR",
"name": "Employee Boarding Activity",
Expand All @@ -102,5 +103,6 @@
"quick_entry": 1,
"sort_field": "modified",
"sort_order": "DESC",
"states": [],
"track_changes": 1
}
20 changes: 14 additions & 6 deletions erpnext/hr/doctype/employee_onboarding/employee_onboarding.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@

frappe.ui.form.on('Employee Onboarding', {
setup: function(frm) {
frm.add_fetch("employee_onboarding_template", "company", "company");
frm.add_fetch("employee_onboarding_template", "department", "department");
frm.add_fetch("employee_onboarding_template", "designation", "designation");
frm.add_fetch("employee_onboarding_template", "employee_grade", "employee_grade");


frm.set_query("job_applicant", function () {
return {
filters:{
Expand Down Expand Up @@ -71,5 +65,19 @@ frappe.ui.form.on('Employee Onboarding', {
}
});
}
},

job_applicant: function(frm) {
if (frm.doc.job_applicant) {
frappe.db.get_value('Employee', {'job_applicant': frm.doc.job_applicant}, 'name', (r) => {
if (r.name) {
frm.set_value('employee', r.name);
} else {
frm.set_value('employee', '');
}
});
} else {
frm.set_value('employee', '');
}
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -92,27 +92,31 @@
"options": "Employee Onboarding Template"
},
{
"fetch_from": "employee_onboarding_template.company",
"fieldname": "company",
"fieldtype": "Link",
"label": "Company",
"options": "Company",
"reqd": 1
},
{
"fetch_from": "employee_onboarding_template.department",
"fieldname": "department",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Department",
"options": "Department"
},
{
"fetch_from": "employee_onboarding_template.designation",
"fieldname": "designation",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Designation",
"options": "Designation"
},
{
"fetch_from": "employee_onboarding_template.employee_grade",
"fieldname": "employee_grade",
"fieldtype": "Link",
"label": "Employee Grade",
Expand Down Expand Up @@ -170,10 +174,11 @@
],
"is_submittable": 1,
"links": [],
"modified": "2021-07-30 14:55:04.560683",
"modified": "2022-01-29 12:33:57.120384",
"modified_by": "Administrator",
"module": "HR",
"name": "Employee Onboarding",
"naming_rule": "Expression (old style)",
"owner": "Administrator",
"permissions": [
{
Expand All @@ -194,6 +199,7 @@
],
"sort_field": "modified",
"sort_order": "DESC",
"states": [],
"title_field": "employee_name",
"track_changes": 1
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,15 @@ class IncompleteTaskError(frappe.ValidationError): pass
class EmployeeOnboarding(EmployeeBoardingController):
def validate(self):
super(EmployeeOnboarding, self).validate()
self.set_employee()
self.validate_duplicate_employee_onboarding()

def set_employee(self):
if not self.employee:
self.employee = frappe.db.get_value('Employee', {'job_applicant': self.job_applicant}, 'name')

def validate_duplicate_employee_onboarding(self):
emp_onboarding = frappe.db.exists("Employee Onboarding", {"job_applicant": self.job_applicant})
emp_onboarding = frappe.db.exists("Employee Onboarding", {"job_applicant": self.job_applicant, "docstatus": ("!=", 2)})
if emp_onboarding and emp_onboarding != self.name:
frappe.throw(_("Employee Onboarding: {0} already exists for Job Applicant: {1}").format(frappe.bold(emp_onboarding), frappe.bold(self.job_applicant)))

Expand Down
1 change: 1 addition & 0 deletions erpnext/hr/doctype/job_offer/job_offer.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def set_missing_values(source, target):
"doctype": "Employee",
"field_map": {
"applicant_name": "employee_name",
"offer_date": "scheduled_confirmation_date"
}}
}, target_doc, set_missing_values)
return doc
10 changes: 6 additions & 4 deletions erpnext/projects/doctype/project/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,13 @@
{
"fieldname": "actual_start_date",
"fieldtype": "Data",
"label": "Actual Start Date",
"label": "Actual Start Date (via Time Sheet)",
"read_only": 1
},
{
"fieldname": "actual_time",
"fieldtype": "Float",
"label": "Actual Time (in Hours)",
"label": "Actual Time (in Hours via Time Sheet)",
"read_only": 1
},
{
Expand All @@ -251,7 +251,7 @@
{
"fieldname": "actual_end_date",
"fieldtype": "Date",
"label": "Actual End Date",
"label": "Actual End Date (via Time Sheet)",
"oldfieldname": "act_completion_date",
"oldfieldtype": "Date",
"read_only": 1
Expand Down Expand Up @@ -458,10 +458,11 @@
"index_web_pages_for_search": 1,
"links": [],
"max_attachments": 4,
"modified": "2021-04-28 16:36:11.654632",
"modified": "2022-01-29 13:58:27.712714",
"modified_by": "Administrator",
"module": "Projects",
"name": "Project",
"naming_rule": "By \"Naming Series\" field",
"owner": "Administrator",
"permissions": [
{
Expand Down Expand Up @@ -499,6 +500,7 @@
"show_name_in_global_search": 1,
"sort_field": "modified",
"sort_order": "DESC",
"states": [],
"timeline_field": "customer",
"title_field": "project_name",
"track_seen": 1
Expand Down
6 changes: 4 additions & 2 deletions erpnext/projects/doctype/task/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@
{
"fieldname": "actual_time",
"fieldtype": "Float",
"label": "Actual Time (in hours)",
"label": "Actual Time (in Hours via Time Sheet)",
"read_only": 1
},
{
Expand Down Expand Up @@ -397,10 +397,11 @@
"is_tree": 1,
"links": [],
"max_attachments": 5,
"modified": "2021-04-16 12:46:51.556741",
"modified": "2022-01-29 13:58:47.005241",
"modified_by": "Administrator",
"module": "Projects",
"name": "Task",
"naming_rule": "Expression (old style)",
"nsm_parent_field": "parent_task",
"owner": "Administrator",
"permissions": [
Expand All @@ -421,6 +422,7 @@
"show_preview_popup": 1,
"sort_field": "modified",
"sort_order": "DESC",
"states": [],
"timeline_field": "project",
"title_field": "subject",
"track_seen": 1
Expand Down

0 comments on commit 4a09dc4

Please sign in to comment.