From a5afd96019fd3f7b21ec7e0e7b1569710f24557b Mon Sep 17 00:00:00 2001 From: Shreya Date: Wed, 20 Jun 2018 15:48:04 +0530 Subject: [PATCH 1/3] Employee Onboarding and Separation lists --- .../employee_onboarding/employee_onboarding_list.js | 7 +++++++ .../employee_separation/employee_separation_list.js | 7 +++++++ 2 files changed, 14 insertions(+) create mode 100644 erpnext/hr/doctype/employee_onboarding/employee_onboarding_list.js create mode 100644 erpnext/hr/doctype/employee_separation/employee_separation_list.js diff --git a/erpnext/hr/doctype/employee_onboarding/employee_onboarding_list.js b/erpnext/hr/doctype/employee_onboarding/employee_onboarding_list.js new file mode 100644 index 0000000000..c14d7a5a8e --- /dev/null +++ b/erpnext/hr/doctype/employee_onboarding/employee_onboarding_list.js @@ -0,0 +1,7 @@ +frappe.listview_settings['Employee Onboarding'] = { + add_fields: ["boarding_status", "employee_name", "date_of_joining", "department"], + filters:[["boarding_status","=", "Pending"]], + get_indicator: function(doc) { + return [__(doc.boarding_status), frappe.utils.guess_colour(doc.boarding_status), "status,=," + doc.boarding_status]; + } + }; diff --git a/erpnext/hr/doctype/employee_separation/employee_separation_list.js b/erpnext/hr/doctype/employee_separation/employee_separation_list.js new file mode 100644 index 0000000000..d23802c08c --- /dev/null +++ b/erpnext/hr/doctype/employee_separation/employee_separation_list.js @@ -0,0 +1,7 @@ +frappe.listview_settings['Employee Separation'] = { + add_fields: ["boarding_status", "employee_name", "date_of_joining", "department"], + filters:[["boarding_status","=", "Pending"]], + get_indicator: function(doc) { + return [__(doc.boarding_status), frappe.utils.guess_colour(doc.boarding_status), "status,=," + doc.boarding_status]; + } + }; From 5c6ade4bd8bb9ad0562fd53246c2f4f5590ec3ea Mon Sep 17 00:00:00 2001 From: Shreya Date: Wed, 20 Jun 2018 15:48:27 +0530 Subject: [PATCH 2/3] Update and set status on the basis of project completion --- .../employee_onboarding/employee_onboarding.js | 14 ++++++++++++++ .../employee_onboarding/employee_onboarding.py | 2 +- .../employee_separation/employee_separation.js | 14 ++++++++++++++ erpnext/hr/utils.py | 12 ++++++++++++ 4 files changed, 41 insertions(+), 1 deletion(-) diff --git a/erpnext/hr/doctype/employee_onboarding/employee_onboarding.js b/erpnext/hr/doctype/employee_onboarding/employee_onboarding.js index e95e260fa9..ffba940013 100644 --- a/erpnext/hr/doctype/employee_onboarding/employee_onboarding.js +++ b/erpnext/hr/doctype/employee_onboarding/employee_onboarding.js @@ -32,6 +32,20 @@ frappe.ui.form.on('Employee Onboarding', { }, __("Make")); frm.page.set_inner_btn_group_as_primary(__("Make")); } + if (frm.doc.docstatus === 1 && frm.doc.project) { + frappe.call({ + method: "erpnext.hr.utils.get_boarding_status", + args: { + "project": frm.doc.project + }, + callback: function(r) { + if (r.message) { + frm.set_value('boarding_status', r.message) + } + refresh_field("boarding_status"); + } + }); + } }, diff --git a/erpnext/hr/doctype/employee_onboarding/employee_onboarding.py b/erpnext/hr/doctype/employee_onboarding/employee_onboarding.py index fab084698b..29124fce24 100644 --- a/erpnext/hr/doctype/employee_onboarding/employee_onboarding.py +++ b/erpnext/hr/doctype/employee_onboarding/employee_onboarding.py @@ -5,6 +5,7 @@ from __future__ import unicode_literals import frappe from frappe import _ +from frappe.utils import flt from erpnext.hr.utils import EmployeeBoardingController from frappe.model.mapper import get_mapped_doc @@ -31,7 +32,6 @@ class EmployeeOnboarding(EmployeeBoardingController): def on_cancel(self): super(EmployeeOnboarding, self).on_cancel() - @frappe.whitelist() def make_employee(source_name, target_doc=None): doc = frappe.get_doc("Employee Onboarding", source_name) diff --git a/erpnext/hr/doctype/employee_separation/employee_separation.js b/erpnext/hr/doctype/employee_separation/employee_separation.js index 33830796b6..6ef73eb550 100644 --- a/erpnext/hr/doctype/employee_separation/employee_separation.js +++ b/erpnext/hr/doctype/employee_separation/employee_separation.js @@ -23,6 +23,20 @@ frappe.ui.form.on('Employee Separation', { frappe.set_route('List', 'Task', {project: frm.doc.project}); },__("View")); } + if (frm.doc.docstatus === 1 && frm.doc.project) { + frappe.call({ + method: "erpnext.hr.utils.get_boarding_status", + args: { + "project": frm.doc.project + }, + callback: function(r) { + if (r.message) { + frm.set_value('boarding_status', r.message) + } + refresh_field("boarding_status"); + } + }); + } }, employee_separation_template: function(frm) { diff --git a/erpnext/hr/utils.py b/erpnext/hr/utils.py index abbf302e5b..7a861ac2bc 100644 --- a/erpnext/hr/utils.py +++ b/erpnext/hr/utils.py @@ -35,6 +35,7 @@ class EmployeeBoardingController(Document): "company": self.company }).insert(ignore_permissions=True) self.db_set("project", project.name) + self.db_set("boarding_status", "Pending") # create the task for the given project and assign to the concerned person for activity in self.activities: @@ -84,6 +85,17 @@ def get_onboarding_details(parent, parenttype): filters={"parent": parent, "parenttype": parenttype}, order_by= "idx") +@frappe.whitelist() +def get_boarding_status(project): + status = 'Pending' + if project: + doc = frappe.get_doc('Project', project) + if flt(doc.percent_complete) > 0.0 and flt(doc.percent_complete) < 100.0: + status = 'In Process' + elif flt(doc.percent_complete) == 100.0: + status = 'Completed' + return status + def set_employee_name(doc): if doc.employee and not doc.employee_name: doc.employee_name = frappe.db.get_value("Employee", doc.employee, "employee_name") From 3fd21d4273fb436c2482155efc8d9b973c149985 Mon Sep 17 00:00:00 2001 From: Shreya Date: Wed, 20 Jun 2018 16:09:16 +0530 Subject: [PATCH 3/3] Fix codacy --- .../hr/doctype/employee_onboarding/employee_onboarding.js | 2 +- .../hr/doctype/employee_onboarding/employee_onboarding.py | 1 - .../doctype/employee_onboarding/employee_onboarding_list.js | 6 +++--- .../hr/doctype/employee_separation/employee_separation.js | 2 +- .../doctype/employee_separation/employee_separation_list.js | 6 +++--- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/erpnext/hr/doctype/employee_onboarding/employee_onboarding.js b/erpnext/hr/doctype/employee_onboarding/employee_onboarding.js index ffba940013..08615888d3 100644 --- a/erpnext/hr/doctype/employee_onboarding/employee_onboarding.js +++ b/erpnext/hr/doctype/employee_onboarding/employee_onboarding.js @@ -40,7 +40,7 @@ frappe.ui.form.on('Employee Onboarding', { }, callback: function(r) { if (r.message) { - frm.set_value('boarding_status', r.message) + frm.set_value('boarding_status', r.message); } refresh_field("boarding_status"); } diff --git a/erpnext/hr/doctype/employee_onboarding/employee_onboarding.py b/erpnext/hr/doctype/employee_onboarding/employee_onboarding.py index 29124fce24..9262a06a3f 100644 --- a/erpnext/hr/doctype/employee_onboarding/employee_onboarding.py +++ b/erpnext/hr/doctype/employee_onboarding/employee_onboarding.py @@ -5,7 +5,6 @@ from __future__ import unicode_literals import frappe from frappe import _ -from frappe.utils import flt from erpnext.hr.utils import EmployeeBoardingController from frappe.model.mapper import get_mapped_doc diff --git a/erpnext/hr/doctype/employee_onboarding/employee_onboarding_list.js b/erpnext/hr/doctype/employee_onboarding/employee_onboarding_list.js index c14d7a5a8e..a33619bed4 100644 --- a/erpnext/hr/doctype/employee_onboarding/employee_onboarding_list.js +++ b/erpnext/hr/doctype/employee_onboarding/employee_onboarding_list.js @@ -2,6 +2,6 @@ frappe.listview_settings['Employee Onboarding'] = { add_fields: ["boarding_status", "employee_name", "date_of_joining", "department"], filters:[["boarding_status","=", "Pending"]], get_indicator: function(doc) { - return [__(doc.boarding_status), frappe.utils.guess_colour(doc.boarding_status), "status,=," + doc.boarding_status]; - } - }; + return [__(doc.boarding_status), frappe.utils.guess_colour(doc.boarding_status), "status,=," + doc.boarding_status]; + } +}; diff --git a/erpnext/hr/doctype/employee_separation/employee_separation.js b/erpnext/hr/doctype/employee_separation/employee_separation.js index 6ef73eb550..9a75c16317 100644 --- a/erpnext/hr/doctype/employee_separation/employee_separation.js +++ b/erpnext/hr/doctype/employee_separation/employee_separation.js @@ -31,7 +31,7 @@ frappe.ui.form.on('Employee Separation', { }, callback: function(r) { if (r.message) { - frm.set_value('boarding_status', r.message) + frm.set_value('boarding_status', r.message); } refresh_field("boarding_status"); } diff --git a/erpnext/hr/doctype/employee_separation/employee_separation_list.js b/erpnext/hr/doctype/employee_separation/employee_separation_list.js index d23802c08c..11487cc6f0 100644 --- a/erpnext/hr/doctype/employee_separation/employee_separation_list.js +++ b/erpnext/hr/doctype/employee_separation/employee_separation_list.js @@ -2,6 +2,6 @@ frappe.listview_settings['Employee Separation'] = { add_fields: ["boarding_status", "employee_name", "date_of_joining", "department"], filters:[["boarding_status","=", "Pending"]], get_indicator: function(doc) { - return [__(doc.boarding_status), frappe.utils.guess_colour(doc.boarding_status), "status,=," + doc.boarding_status]; - } - }; + return [__(doc.boarding_status), frappe.utils.guess_colour(doc.boarding_status), "status,=," + doc.boarding_status]; + } +};