Update and set status on the basis of project completion
This commit is contained in:
parent
a5afd96019
commit
5c6ade4bd8
@ -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");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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) {
|
||||
|
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user