Merge pull request #14608 from shreyashah115/fix-onboard
[Enhance] Employee Onboarding & Separation
This commit is contained in:
		
						commit
						22bb61b58c
					
				| @ -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"); | ||||
| 				} | ||||
| 			}); | ||||
| 		} | ||||
| 
 | ||||
| 	}, | ||||
| 
 | ||||
|  | ||||
| @ -31,7 +31,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) | ||||
|  | ||||
| @ -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]; | ||||
| 	} | ||||
| }; | ||||
| @ -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) { | ||||
|  | ||||
| @ -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]; | ||||
| 	} | ||||
| }; | ||||
| @ -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…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user