Browse Source
* feat: Employee Grievance * feat: link to desk and automatic unsuspend * test: Employee Grievance * fix: Sider and Translation * fix: sider * fix: formatting * feat: changes requested * feat: Employee Grievance * feat: link to desk and automatic unsuspend * test: Employee Grievance * fix: Sider and Translation * fix: sider * fix: formatting * feat: changes requested * fix: patch test and sider issue * fix: make Employee Responsible non-mandatory since there cannot be an employee responsible for all sorts of grievances - show pay cut and suspension buttons only if Employee Resposible is set - some label changes * feat: added subject field for more context - set title for documents - added list view settings - refactor suspend and unsuspend functions - add submit and cancel perms for system and hr managers - fix tests * fix: sider issues * fix: removed suspension and paycut * fix:sider * fix: test * fix: test * fix: resolved Conflicts * fix: sider * fix: remove debugging print statements * fix: validation message * fix: unnecessary comma Co-authored-by: Rucha Mahabal <ruchamahabal2@gmail.com>develop
Anurag Mishra
3 years ago
committed by
GitHub
20 changed files with 516 additions and 16 deletions
@ -0,0 +1,39 @@ |
|||
// Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors
|
|||
// For license information, please see license.txt
|
|||
|
|||
frappe.ui.form.on('Employee Grievance', { |
|||
setup: function(frm) { |
|||
frm.set_query('grievance_against_party', function() { |
|||
return { |
|||
filters: { |
|||
name: ['in', [ |
|||
'Company', 'Department', 'Employee Group', 'Employee Grade', 'Employee'] |
|||
] |
|||
} |
|||
}; |
|||
}); |
|||
frm.set_query('associated_document_type', function() { |
|||
let ignore_modules = ["Setup", "Core", "Integrations", "Automation", "Website", |
|||
"Utilities", "Event Streaming", "Social", "Chat", "Data Migration", "Printing", "Desk", "Custom"]; |
|||
return { |
|||
filters: { |
|||
istable: 0, |
|||
issingle: 0, |
|||
module: ["Not In", ignore_modules] |
|||
} |
|||
}; |
|||
}); |
|||
}, |
|||
|
|||
grievance_against_party: function(frm) { |
|||
let filters = {}; |
|||
if (frm.doc.grievance_against_party == 'Employee' && frm.doc.raised_by) { |
|||
filters.name = ["!=", frm.doc.raised_by]; |
|||
} |
|||
frm.set_query('grievance_against', function() { |
|||
return { |
|||
filters: filters |
|||
}; |
|||
}); |
|||
}, |
|||
}); |
@ -0,0 +1,261 @@ |
|||
{ |
|||
"actions": [], |
|||
"autoname": "HR-GRIEV-.YYYY.-.#####", |
|||
"creation": "2021-05-11 13:41:51.485295", |
|||
"doctype": "DocType", |
|||
"editable_grid": 1, |
|||
"engine": "InnoDB", |
|||
"field_order": [ |
|||
"subject", |
|||
"raised_by", |
|||
"employee_name", |
|||
"designation", |
|||
"column_break_3", |
|||
"date", |
|||
"status", |
|||
"reports_to", |
|||
"grievance_details_section", |
|||
"grievance_against_party", |
|||
"grievance_against", |
|||
"grievance_type", |
|||
"column_break_11", |
|||
"associated_document_type", |
|||
"associated_document", |
|||
"section_break_14", |
|||
"description", |
|||
"investigation_details_section", |
|||
"cause_of_grievance", |
|||
"resolution_details_section", |
|||
"resolved_by", |
|||
"resolution_date", |
|||
"employee_responsible", |
|||
"column_break_16", |
|||
"resolution_detail", |
|||
"amended_from" |
|||
], |
|||
"fields": [ |
|||
{ |
|||
"fieldname": "grievance_type", |
|||
"fieldtype": "Link", |
|||
"in_list_view": 1, |
|||
"label": "Grievance Type", |
|||
"options": "Grievance Type", |
|||
"reqd": 1 |
|||
}, |
|||
{ |
|||
"fieldname": "column_break_3", |
|||
"fieldtype": "Column Break" |
|||
}, |
|||
{ |
|||
"fieldname": "date", |
|||
"fieldtype": "Date", |
|||
"in_list_view": 1, |
|||
"label": "Date ", |
|||
"reqd": 1 |
|||
}, |
|||
{ |
|||
"default": "Open", |
|||
"fieldname": "status", |
|||
"fieldtype": "Select", |
|||
"in_list_view": 1, |
|||
"label": "Status", |
|||
"options": "Open\nInvestigated\nResolved\nInvalid", |
|||
"reqd": 1 |
|||
}, |
|||
{ |
|||
"fieldname": "description", |
|||
"fieldtype": "Text", |
|||
"label": "Description", |
|||
"reqd": 1 |
|||
}, |
|||
{ |
|||
"fieldname": "cause_of_grievance", |
|||
"fieldtype": "Text", |
|||
"label": "Cause of Grievance", |
|||
"mandatory_depends_on": "eval: doc.status == \"Investigated\" || doc.status == \"Resolved\"" |
|||
}, |
|||
{ |
|||
"fieldname": "resolution_details_section", |
|||
"fieldtype": "Section Break", |
|||
"label": "Resolution Details" |
|||
}, |
|||
{ |
|||
"fieldname": "resolved_by", |
|||
"fieldtype": "Link", |
|||
"label": "Resolved By", |
|||
"mandatory_depends_on": "eval: doc.status == \"Resolved\"", |
|||
"options": "User" |
|||
}, |
|||
{ |
|||
"fieldname": "employee_responsible", |
|||
"fieldtype": "Link", |
|||
"label": "Employee Responsible ", |
|||
"options": "Employee" |
|||
}, |
|||
{ |
|||
"fieldname": "resolution_detail", |
|||
"fieldtype": "Small Text", |
|||
"label": "Resolution Details", |
|||
"mandatory_depends_on": "eval: doc.status == \"Resolved\"" |
|||
}, |
|||
{ |
|||
"fieldname": "column_break_16", |
|||
"fieldtype": "Column Break" |
|||
}, |
|||
{ |
|||
"fieldname": "resolution_date", |
|||
"fieldtype": "Date", |
|||
"label": "Resolution Date", |
|||
"mandatory_depends_on": "eval: doc.status == \"Resolved\"" |
|||
}, |
|||
{ |
|||
"fieldname": "grievance_against", |
|||
"fieldtype": "Dynamic Link", |
|||
"label": "Grievance Against", |
|||
"options": "grievance_against_party", |
|||
"reqd": 1 |
|||
}, |
|||
{ |
|||
"fieldname": "raised_by", |
|||
"fieldtype": "Link", |
|||
"label": "Raised By", |
|||
"options": "Employee", |
|||
"reqd": 1 |
|||
}, |
|||
{ |
|||
"fieldname": "amended_from", |
|||
"fieldtype": "Link", |
|||
"label": "Amended From", |
|||
"no_copy": 1, |
|||
"options": "Employee Grievance", |
|||
"print_hide": 1, |
|||
"read_only": 1 |
|||
}, |
|||
{ |
|||
"fetch_from": "raised_by.designation", |
|||
"fieldname": "designation", |
|||
"fieldtype": "Link", |
|||
"label": "Designation", |
|||
"options": "Designation", |
|||
"read_only": 1 |
|||
}, |
|||
{ |
|||
"fetch_from": "raised_by.reports_to", |
|||
"fieldname": "reports_to", |
|||
"fieldtype": "Link", |
|||
"label": "Reports To", |
|||
"options": "Employee", |
|||
"read_only": 1 |
|||
}, |
|||
{ |
|||
"fieldname": "grievance_details_section", |
|||
"fieldtype": "Section Break", |
|||
"label": "Grievance Details" |
|||
}, |
|||
{ |
|||
"fieldname": "column_break_11", |
|||
"fieldtype": "Column Break" |
|||
}, |
|||
{ |
|||
"fieldname": "section_break_14", |
|||
"fieldtype": "Section Break" |
|||
}, |
|||
{ |
|||
"fieldname": "grievance_against_party", |
|||
"fieldtype": "Link", |
|||
"in_list_view": 1, |
|||
"label": "Grievance Against Party", |
|||
"options": "DocType", |
|||
"reqd": 1 |
|||
}, |
|||
{ |
|||
"fieldname": "associated_document_type", |
|||
"fieldtype": "Link", |
|||
"label": "Associated Document Type", |
|||
"options": "DocType" |
|||
}, |
|||
{ |
|||
"fieldname": "associated_document", |
|||
"fieldtype": "Dynamic Link", |
|||
"label": "Associated Document", |
|||
"options": "associated_document_type" |
|||
}, |
|||
{ |
|||
"fieldname": "investigation_details_section", |
|||
"fieldtype": "Section Break", |
|||
"label": "Investigation Details" |
|||
}, |
|||
{ |
|||
"fetch_from": "raised_by.employee_name", |
|||
"fieldname": "employee_name", |
|||
"fieldtype": "Data", |
|||
"label": "Employee Name", |
|||
"read_only": 1 |
|||
}, |
|||
{ |
|||
"fieldname": "subject", |
|||
"fieldtype": "Data", |
|||
"label": "Subject", |
|||
"reqd": 1 |
|||
} |
|||
], |
|||
"index_web_pages_for_search": 1, |
|||
"is_submittable": 1, |
|||
"links": [], |
|||
"modified": "2021-06-21 12:51:01.499486", |
|||
"modified_by": "Administrator", |
|||
"module": "HR", |
|||
"name": "Employee Grievance", |
|||
"owner": "Administrator", |
|||
"permissions": [ |
|||
{ |
|||
"amend": 1, |
|||
"cancel": 1, |
|||
"create": 1, |
|||
"delete": 1, |
|||
"email": 1, |
|||
"export": 1, |
|||
"print": 1, |
|||
"read": 1, |
|||
"report": 1, |
|||
"role": "System Manager", |
|||
"select": 1, |
|||
"share": 1, |
|||
"submit": 1, |
|||
"write": 1 |
|||
}, |
|||
{ |
|||
"amend": 1, |
|||
"cancel": 1, |
|||
"create": 1, |
|||
"delete": 1, |
|||
"email": 1, |
|||
"export": 1, |
|||
"print": 1, |
|||
"read": 1, |
|||
"report": 1, |
|||
"role": "HR Manager", |
|||
"select": 1, |
|||
"share": 1, |
|||
"submit": 1, |
|||
"write": 1 |
|||
}, |
|||
{ |
|||
"create": 1, |
|||
"delete": 1, |
|||
"email": 1, |
|||
"export": 1, |
|||
"print": 1, |
|||
"read": 1, |
|||
"report": 1, |
|||
"role": "HR User", |
|||
"share": 1, |
|||
"write": 1 |
|||
} |
|||
], |
|||
"search_fields": "subject,raised_by,grievance_against_party", |
|||
"sort_field": "modified", |
|||
"sort_order": "DESC", |
|||
"title_field": "subject", |
|||
"track_changes": 1 |
|||
} |
@ -0,0 +1,15 @@ |
|||
# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors |
|||
# For license information, please see license.txt |
|||
|
|||
import frappe |
|||
from frappe import _, bold |
|||
from frappe.model.document import Document |
|||
|
|||
class EmployeeGrievance(Document): |
|||
def on_submit(self): |
|||
if self.status not in ["Invalid", "Resolved"]: |
|||
frappe.throw(_("Only Employee Grievance with status {0} or {1} can be submitted").format( |
|||
bold("Invalid"), |
|||
bold("Resolved")) |
|||
) |
|||
|
@ -0,0 +1,12 @@ |
|||
frappe.listview_settings["Employee Grievance"] = { |
|||
has_indicator_for_draft: 1, |
|||
get_indicator: function(doc) { |
|||
var colors = { |
|||
"Open": "red", |
|||
"Investigated": "orange", |
|||
"Resolved": "green", |
|||
"Invalid": "grey" |
|||
}; |
|||
return [__(doc.status), colors[doc.status], "status,=," + doc.status]; |
|||
} |
|||
}; |
@ -0,0 +1,51 @@ |
|||
# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and Contributors |
|||
# See license.txt |
|||
|
|||
import frappe |
|||
import unittest |
|||
from frappe.utils import today |
|||
from erpnext.hr.doctype.employee.test_employee import make_employee |
|||
class TestEmployeeGrievance(unittest.TestCase): |
|||
def test_create_employee_grievance(self): |
|||
create_employee_grievance() |
|||
|
|||
def create_employee_grievance(): |
|||
grievance_type = create_grievance_type() |
|||
emp_1 = make_employee("test_emp_grievance_@example.com", company="_Test Company") |
|||
emp_2 = make_employee("testculprit@example.com", company="_Test Company") |
|||
|
|||
grievance = frappe.new_doc("Employee Grievance") |
|||
grievance.subject = "Test Employee Grievance" |
|||
grievance.raised_by = emp_1 |
|||
grievance.date = today() |
|||
grievance.grievance_type = grievance_type |
|||
grievance.grievance_against_party = "Employee" |
|||
grievance.grievance_against = emp_2 |
|||
grievance.description = "test descrip" |
|||
|
|||
#set cause |
|||
grievance.cause_of_grievance = "test cause" |
|||
|
|||
#resolution details |
|||
grievance.resolution_date = today() |
|||
grievance.resolution_detail = "test resolution detail" |
|||
grievance.resolved_by = "test_emp_grievance_@example.com" |
|||
grievance.employee_responsible = emp_2 |
|||
grievance.status = "Resolved" |
|||
|
|||
grievance.save() |
|||
grievance.submit() |
|||
|
|||
return grievance |
|||
|
|||
|
|||
def create_grievance_type(): |
|||
if frappe.db.exists("Grievance Type", "Employee Abuse"): |
|||
return frappe.get_doc("Grievance Type", "Employee Abuse") |
|||
grievance_type = frappe.new_doc("Grievance Type") |
|||
grievance_type.name = "Employee Abuse" |
|||
grievance_type.description = "Test" |
|||
grievance_type.save() |
|||
|
|||
return grievance_type.name |
|||
|
@ -0,0 +1,8 @@ |
|||
// Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors
|
|||
// For license information, please see license.txt
|
|||
|
|||
frappe.ui.form.on('Grievance Type', { |
|||
// refresh: function(frm) {
|
|||
|
|||
// }
|
|||
}); |
@ -0,0 +1,70 @@ |
|||
{ |
|||
"actions": [], |
|||
"autoname": "Prompt", |
|||
"creation": "2021-05-11 12:41:50.256071", |
|||
"doctype": "DocType", |
|||
"editable_grid": 1, |
|||
"engine": "InnoDB", |
|||
"field_order": [ |
|||
"section_break_5", |
|||
"description" |
|||
], |
|||
"fields": [ |
|||
{ |
|||
"fieldname": "section_break_5", |
|||
"fieldtype": "Section Break" |
|||
}, |
|||
{ |
|||
"fieldname": "description", |
|||
"fieldtype": "Text", |
|||
"label": "Description" |
|||
} |
|||
], |
|||
"index_web_pages_for_search": 1, |
|||
"links": [], |
|||
"modified": "2021-06-21 12:54:37.764712", |
|||
"modified_by": "Administrator", |
|||
"module": "HR", |
|||
"name": "Grievance Type", |
|||
"owner": "Administrator", |
|||
"permissions": [ |
|||
{ |
|||
"create": 1, |
|||
"delete": 1, |
|||
"email": 1, |
|||
"export": 1, |
|||
"print": 1, |
|||
"read": 1, |
|||
"report": 1, |
|||
"role": "System Manager", |
|||
"share": 1, |
|||
"write": 1 |
|||
}, |
|||
{ |
|||
"create": 1, |
|||
"delete": 1, |
|||
"email": 1, |
|||
"export": 1, |
|||
"print": 1, |
|||
"read": 1, |
|||
"report": 1, |
|||
"role": "HR Manager", |
|||
"share": 1, |
|||
"write": 1 |
|||
}, |
|||
{ |
|||
"create": 1, |
|||
"delete": 1, |
|||
"email": 1, |
|||
"export": 1, |
|||
"print": 1, |
|||
"read": 1, |
|||
"report": 1, |
|||
"role": "HR User", |
|||
"share": 1, |
|||
"write": 1 |
|||
} |
|||
], |
|||
"sort_field": "modified", |
|||
"sort_order": "DESC" |
|||
} |
@ -0,0 +1,8 @@ |
|||
# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors |
|||
# For license information, please see license.txt |
|||
|
|||
# import frappe |
|||
from frappe.model.document import Document |
|||
|
|||
class GrievanceType(Document): |
|||
pass |
@ -0,0 +1,8 @@ |
|||
# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and Contributors |
|||
# See license.txt |
|||
|
|||
# import frappe |
|||
import unittest |
|||
|
|||
class TestGrievanceType(unittest.TestCase): |
|||
pass |
Loading…
Reference in new issue