Update and set status on the basis of project completion
diff --git a/erpnext/hr/doctype/employee_onboarding/employee_onboarding.js b/erpnext/hr/doctype/employee_onboarding/employee_onboarding.js
index e95e260..ffba940 100644
--- a/erpnext/hr/doctype/employee_onboarding/employee_onboarding.js
+++ b/erpnext/hr/doctype/employee_onboarding/employee_onboarding.js
@@ -32,6 +32,20 @@
}, __("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 fab0846..29124fc 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 @@
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 3383079..6ef73eb 100644
--- a/erpnext/hr/doctype/employee_separation/employee_separation.js
+++ b/erpnext/hr/doctype/employee_separation/employee_separation.js
@@ -23,6 +23,20 @@
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 abbf302..7a861ac 100644
--- a/erpnext/hr/utils.py
+++ b/erpnext/hr/utils.py
@@ -35,6 +35,7 @@
"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 @@
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")