Skip to content

Commit

Permalink
fix(Navigation): Add override_doctype_dashboards hook for adding HR…
Browse files Browse the repository at this point in the history
…/Payroll references to other form dashboards

- Employee, Holiday list, Project, Task, Timesheet
  • Loading branch information
ruchamahabal committed Jun 24, 2022
1 parent 4d0aa1f commit 6f9ef74
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 3 deletions.
10 changes: 7 additions & 3 deletions hrms/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,13 @@
# each overriding function accepts a `data` argument;
# generated from the base implementation of the doctype dashboard,
# along with any modifications made in other Frappe apps
# override_doctype_dashboards = {
# "Task": "hrms.task.get_dashboard_data"
# }
override_doctype_dashboards = {
"Employee": "hrms.overrides.dashboard_overrides.get_dashboard_for_employee",
"Holiday List": "hrms.overrides.dashboard_overrides.get_dashboard_for_holiday_list",
"Task": "hrms.overrides.dashboard_overrides.get_dashboard_for_project",
"Project": "hrms.overrides.dashboard_overrides.get_dashboard_for_project",
"Timesheet": "hrms.overrides.dashboard_overrides.get_dashboard_for_timesheet",
}

# exempt linked doctypes from being automatically cancelled
#
Expand Down
75 changes: 75 additions & 0 deletions hrms/overrides/dashboard_overrides.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Copyright (c) 2022, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt

from frappe import _


def get_dashboard_for_employee(data):
return {
"heatmap": True,
"heatmap_message": _("This is based on the attendance of this Employee"),
"fieldname": "employee",
"non_standard_fieldnames": {"Bank Account": "party", "Employee Grievance": "raised_by"},
"transactions": [
{"label": _("Attendance"), "items": ["Attendance", "Attendance Request", "Employee Checkin"]},
{
"label": _("Leave"),
"items": ["Leave Application", "Leave Allocation", "Leave Policy Assignment"],
},
{
"label": _("Lifecycle"),
"items": [
"Employee Onboarding",
"Employee Transfer",
"Employee Promotion",
"Employee Grievance",
],
},
{
"label": _("Exit"),
"items": ["Employee Separation", "Exit Interview", "Full and Final Statement"],
},
{"label": _("Shift"), "items": ["Shift Request", "Shift Assignment"]},
{"label": _("Expense"), "items": ["Expense Claim", "Travel Request", "Employee Advance"]},
{"label": _("Benefit"), "items": ["Employee Benefit Application", "Employee Benefit Claim"]},
{
"label": _("Payroll"),
"items": [
"Salary Structure Assignment",
"Salary Slip",
"Additional Salary",
"Timesheet",
"Employee Incentive",
"Retention Bonus",
"Bank Account",
],
},
{
"label": _("Training"),
"items": ["Training Event", "Training Result", "Training Feedback", "Employee Skill Map"],
},
{"label": _("Evaluation"), "items": ["Appraisal"]},
],
}


def get_dashboard_for_holiday_list(data):
data["non_standard_fieldnames"].update({"Leave Period": "optional_holiday_list"})

data["transactions"].append({"items": ["Leave Period", "Shift Type"]})

return data


def get_dashboard_for_timesheet(data):
data["transactions"].append({"label": _("Payroll"), "items": ["Salary Slip"]})

return data


def get_dashboard_for_project(data):
data["transactions"].append(
{"label": _("Claims"), "items": ["Expense Claim"]},
)

return data

0 comments on commit 6f9ef74

Please sign in to comment.