Introducing a new way to review your PRs.

Read the announcement

frappe / hrms

Open Source HR and Payroll Software

View on GitHub

20 documents · Updated Nov 23, 2026

docs / frappe-extension-lifecycle

Frappe extension lifecycle

Frappe HR extends the Frappe and ERPNext site lifecycle so that HR and payroll features work as one part of the Desk. It adds setup and cleanup actions, connects document events to HR behavior, shapes Desk entry points, and supplies shared services for access, realtime refresh, notifications, subscriptions, and telemetry. See Platform integration and operations for the wider operating model and API and external integration for service-facing interfaces.

Application lifecycle

The application lifecycle turns an installed Frappe HR app into a usable site and removes its site-level changes when the app is disabled or uninstalled. The main hook contract is in hrms/hooks.py, while hrms/setup.py owns most of the setup work.

Installation setup

Installation prepares the site for HR use. It adds HR fields to shared ERPNext records, creates fixtures and notification templates, sets HR and payroll defaults, adds roles and permissions, and runs post-install patches. Company setup also adds regional defaults and salary components when a company's country changes, so the accounting and payroll setup matches the site's active region.

The setup path is designed to work with regional and optional app data. It collects regional custom fields for the countries used by the site and adds loan fields only when the Lending app is installed. This keeps shared ERPNext records aligned with the features that are active on the site.

References: hrms/hooks.py• L97-109 hrms/install.py• L3-19 hrms/setup.py• L13-25 hrms/setup.py• L47-80 hrms/setup.py• L109-134 hrms/setup.py• L552-584 hrms/setup.py• L776-787 hrms/…/company.py• L12-18 hrms/…/company.py• L41-89

Disable and uninstall cleanup

Disabling the app hides its customizations without deleting site data. Enabling it shows the same customizations again. Uninstall removes Frappe HR custom fields, loan-related fields, and company fixtures, so the site does not retain setup artifacts created by the app. Company fixture cleanup checks the countries still used by companies and removes the matching regional defaults when an uninstall needs to reverse setup.

The lifecycle also listens for another app being installed or removed. The Lending app is the supported cross-app case: Frappe HR adds payroll loan fields and Employee Self Service permissions after installation, then removes them before uninstallation.

References: hrms/hooks.py• L113-139 hrms/uninstall.py• L3-19 hrms/setup.py• L27-44 hrms/setup.py• L89-106 hrms/setup.py• L790-804 hrms/…/company.py• L20-39

Desk and workspace experience

Frappe HR presents HR work as a Desk app with focused workspaces rather than as an isolated set of records. The app entry checks both user type and Employee read access, while workspace definitions group setup, transactions, reports, and shortcuts around common HR work.

App entry and access

The app appears on the Frappe app screen with the HR setup route and shared HR assets. Desk access is granted to the Administrator and to users who can read Employee records. Website Users do not see the app because they cannot use Desk routes.

The shared Desk bundle supplies the app-wide client behavior. Doctype-specific JavaScript extends key ERPNext forms such as Employee, Company, Timesheet, Payment Entry, Journal Entry, Delivery Trip, and Bank Transaction. Website routes also map HR application paths and the roster path into Frappe HR pages.

References: hrms/hooks.py• L1-35 hrms/hooks.py• L53-62 hrms/hooks.py• L78-89 hrms/…/desktop.py• L1-5 hrms/…/utils.py• L1028-1042

Workspace navigation

Workspaces give users task-based paths for setup, leave, attendance, recruitment, tenure, expenses, performance, payroll, and tax benefits. Each workspace combines links to records with reports, charts, quick lists, and settings so that a user can move from configuration to daily work without knowing the underlying module layout.

Workspace changes are treated as site data, not only as code defaults. A version patch removes obsolete public workspaces and their sidebar and desktop links. Another patch makes the People workspace sidebar standard when that record exists. These changes keep upgrades from leaving stale navigation behind.

References: hrms/…/hr_setup.json• L1-15 hrms/…/leaves.json• L1-15 hrms/…/shift_&_attendance.json• L1-20 hrms/…/payroll.json• L1-20 hrms/…/recruitment.json• L1-20 hrms/…/tenure.json• L1-20 hrms/…/delete_old_workspaces.py• L1-15 hrms/…/make_people_workspace_sidebar_standard.py• L1-7

Document dashboards

Document dashboards connect an ERPNext record to related HR work. The Employee dashboard adds attendance, leave, lifecycle, exit, shift, expense, benefit, payroll, training, evaluation, and contract links. It also maps non-standard links and an attendance heatmap to the employee timeline. Other overrides add the most relevant HR or accounting records to Holiday List, Timesheet, Project, and Bank Account dashboards.

The Employee dashboard depends on permission-checked timeline data and uses the employee record as the link field for attendance. This gives the record view a recent attendance signal without copying attendance data into the Employee document.

References: hrms/hooks.py• L346-353 hrms/…/dashboard_overrides.py• L7-117 hrms/…/employee_master.py• L149-185

Employee overview

The Employee overview provides a permission-aware summary of one employee's work and pay activity. It combines payroll, attendance, leave balances, open requests, expense claims, advances, and recent transactions into one period-based view.

The view checks Employee access before it reads related records. Each data group can fail without hiding the other groups, so a missing permission or unavailable source produces a marked partial result instead of blocking the whole overview. Payroll data is included only when the user can read Salary Slip records.

References: hrms/…/employee_overview.py• L21-55 hrms/…/employee_overview.py• L58-66 hrms/…/employee_overview.py• L68-205 hrms/…/employee_overview.py• L291-385

Document and event integration

Frappe HR integrates with standard Frappe and ERPNext documents through class overrides and document events. This lets HR rules participate in shared records such as Employee, Company, Timesheet, Payment Entry, Journal Entry, Project, and Loan without creating separate copies of those records.

Standard document extensions

The app replaces selected standard document classes with HR-aware classes. The extensions cover employee naming and onboarding links, employee timesheets, employee payment entries, and employee projects. Employee events also keep recruitment links, approver roles, and transfer references aligned with the employee record.

The Payment Entry extension lets employee-related claims and benefits use the shared payment flow while keeping employee reference and outstanding-amount rules in one place. It supports payment references for Expense Claim, Employee Advance, Leave Encashment, and Gratuity, while preserving the normal ERPNext references for other party types. It also carries the correct outstanding amount and exchange rate into the payment and can write a changed target rate back to a linked Employee Advance.

Employee support also exposes the state needed by assignment actions and retirement-date displays. These checks use the site's permissions and HR Settings so the Employee view does not offer actions that the current site cannot complete.

References: hrms/hooks.py• L159-168 hrms/…/employee_master.py• L11-29 hrms/…/employee_master.py• L31-147 hrms/…/employee_master.py• L188-213 hrms/…/employee_timesheet.py• L1-20 hrms/…/employee_payment_entry.py• L20-30 hrms/…/employee_payment_entry.py• L75-169 hrms/…/employee_payment_entry.py• L183-245 hrms/…/employee_payment_entry.py• L248-353 hrms/…/employee_project.py• L1-25

Document event coordination

Document events keep related HR and accounting state in step. Validation hooks protect active-employee, company, loan, and expense rules. Company events also set payroll and employee-advance accounts, add expense claim account links, apply regional company fixtures, and remove linked HR data when a company is deleted. Update and submit hooks refresh linked employee data, synchronize onboarding and recruiting state, update expense and payroll payment status, and maintain full-and-final and withholding status. Scheduled hooks handle reminders, attendance processing, leave allocation, and other recurring work.

The event map also defines the boundary between request-time work and background work. A document save or submit performs the related state change, while the scheduler sends reminders, processes attendance and shifts, closes expired openings, and captures the daily attendance summary. This separation keeps recurring work out of interactive document requests.

References: hrms/hooks.py• L170-285 hrms/…/employee_master.py• L31-147 hrms/…/company.py• L100-190 hrms/…/company.py• L194-238

Subscription and ERPNext access

The subscription layer connects Frappe HR sites on Frappe Cloud to plan status and ERPNext access. It exposes employee add-on usage for billing and reacts to plan changes from HRMS or ERPNext.

Subscription status

The add-on calculation compares active employees with the employee allowance for the selected plan. Subscription status is checked through the Frappe Cloud marketplace service by using the site secret key. The access update path runs after setup wizard completion and after a relevant subscription update.

References: hrms/subscription_utils.py• L30-70 hrms/subscription_utils.py• L175-180 hrms/hooks.py• L100-109

ERPNext visibility

On Frappe HR hosted sites, subscription setup controls the visibility of ERPNext workspaces and roles and sets the Frappe HR logo in Navbar Settings. The role set is derived from ERPNext modules and doctypes, then excludes roles already supplied by Frappe HR and standard framework roles.

References: hrms/subscription_utils.py• L72-130 hrms/subscription_utils.py• L133-172

Notifications and realtime updates

Notifications connect approval work to both email and the Desk or progressive web app (PWA) client. Installation creates the standard email templates and stores their names in HR Settings. Approval documents can also create a PWA Notification for the employee or approver.

Notification setup

The install step creates templates for leave approval and status, interview reminders and feedback, and exit questionnaires. HR Settings then enables the related defaults and points to those templates. This gives document flows stable names for their email settings without hard-coding template content into each flow.

References: hrms/setup.py• L483-566

Approval notifications

Leave Application, Expense Claim, and Shift Request share an approval notification contract through PWANotificationsMixin. A new request can notify its approver. A change to Approved or Rejected can notify the employee, except when the actor and recipient are the same user.

References: hrms/…/pwa_notifications.py• L7-50 hrms/…/leave_application.py• L103-149 hrms/…/expense_claim.py• L96-105 hrms/…/expense_claim.py• L176-182 hrms/…/shift_request.py• L41-64

Realtime resource refresh

The PWA Notification document stores the sender, recipient, message, read state, and source document. An update tells the recipient client to refetch its notification resource. An insert attempts a push notification when the Frappe version and push service support it. Unsupported push support is non-fatal, and a supported reference creates an HR application link for leave or expense records.

References: hrms/…/pwa_notification.json• L9-24 hrms/…/pwa_notification.py• L9-60 hrms/hooks.py• L346-359

Telemetry

Telemetry provides product-use signals without becoming part of HR transaction success. The backend records selected HR actions and first-use milestones. The Desk client records selected HR navigation and incomplete form exits. Both paths are narrow in scope and skip or absorb failures so telemetry does not change core HR behavior.

Usage and activation signals

Document hooks record recurring actions such as leave, expense, attendance, shift, payroll, recruitment, appraisal, interview, and check-in activity. First-use milestones are limited to the first 30 days of site age and are claimed through the HR Telemetry Milestone record, which prevents repeat activation events. Automated install, migrate, patch, test, and import contexts are excluded.

References: hrms/hooks.py• L235-256 hrms/telemetry.py• L8-55 hrms/telemetry.py• L132-157

The daily attendance pulse is a scheduled summary rather than a document event. It runs only when Frappe telemetry is enabled and the site has active employees. It summarizes the previous day so the shortly-after-midnight schedule reports a complete day.

References: hrms/hooks.py• L270-277 hrms/telemetry.py• L216-257

Desk navigation signals

The Desk client classifies only named HR workspaces, doctypes, and reports. It records landing, workspace, list, form, and report views, plus the start or abandonment of a new HR document. For abandoned drafts it records how many fields are filled, not the field values. Telemetry errors are caught so route changes continue even when the provider is unavailable.

References: hrms/…/telemetry.js• L3-87 hrms/…/telemetry.js• L89-182 hrms/…/telemetry.js• L184-215

Shared integration utilities

Small app-level utilities carry common state across Frappe HR features. They provide after-commit realtime refresh, regional function selection, app visibility checks, and cache invalidation for derived HR data.

Regional behavior

Regional behavior uses the company country or site country to select an override. Functions decorated with allow_regional use the last installed app's matching regional implementation when one exists. The current hook map supplies India-specific tax calculations while leaving the default HR behavior in place for other regions.

References: hrms/__init__.py• L18-54 hrms/hooks.py• L316-322

Cache and client refresh

The shared refetch_resource helper publishes an hrms:refetch_resource event after commit. Document flows use it to refresh employee, shift, and notification resources after saved changes. Holiday List updates clear the cached holiday range used by salary processing so later calculations use the new list.

Holiday utilities also resolve the list that applies to each employee over a date range. They prefer an employee assignment, use company assignments to fill uncovered dates, and return the holiday dates for the lists that are effective during the range. This keeps payroll and attendance calculations aligned with changes in holiday assignments.

References: hrms/__init__.py• L9-15 hrms/…/employee_master.py• L51-55 hrms/…/shift_request.py• L57-60 hrms/…/pwa_notification.py• L27-31 hrms/…/holiday_list.py• L39-117 hrms/…/holiday_list.py• L120-176 hrms/…/holiday_list.py• L412-415

Shared application context

The shared utility module connects common HR flows to Frappe request and session context. Its country lookup is available to guest calls and Jinja templates, while boot data tells the Desk when the site uses HR-only setup. This lets setup and page behavior respond to the site context without adding separate checks to each feature.

The same module supplies inclusive date ranges for payroll, attendance, and shift work. It also resolves an employee's usable email address for flows such as leave communication. These helpers keep common date and contact rules consistent across document features.

References: hrms/…/__init__.py• L11-30 hrms/…/__init__.py• L33-62 hrms/…/__init__.py• L65-66 hrms/hooks.py• L90-111

Change checklist

When these files or sections are changed, remember to consider these:

  • A hook key and its handler must keep the same document event shape. Changes to a standard doctype class must also preserve the ERPNext parent contract.
  • Custom fields and property setters added during install must remain discoverable by the cleanup path. Optional Lending and regional fields must be handled in both setup and removal paths.
  • Company setup and cleanup must use the same regional country scope. Account defaults and expense claim links must remain valid for the company and its currency.
  • Workspace links, sidebar entries, desktop links, and migration patches must agree. Removing or renaming a workspace can leave stale site records if the patch does not cover them.
  • Subscription status changes must keep the add-on count, ERPNext workspace visibility, ERPNext role visibility, and app logo behavior aligned.
  • Telemetry event names and properties are shared across hook handlers, the client route classifier, milestone records, and downstream telemetry consumers. Keep the privacy and context gates intact.
  • A new PWA notification reference needs a matching client route if users must open the source record. Realtime resource keys must match the client cache that consumes them.
  • Regional override keys must match the fully qualified decorated function path. A mismatch silently falls back to the default implementation.
  • Employee payment references must retain the permission checks, outstanding-amount rules, and exchange-rate updates expected by both the source HR document and the shared Payment Entry flow.
  • Employee dashboard links, dynamic link fields, heatmap data, and overview data must continue to use the same Employee identity and permission boundary.
  • Employee overview data groups must keep their response keys and partial-error behavior aligned with the client that renders the summary. Permission checks must remain in place for each source doctype.
  • Holiday List assignment changes must invalidate the salary holiday cache. Range resolution must preserve employee-first selection and company fallback across the requested dates.

Important failure modes

TriggerConsequenceGuard
An install step succeeds only in partThe site can have fields or defaults without the matching permissions or templatesKeep the ordered setup path and let install surface the error rather than hiding it
A custom field is added without a cleanup entryUninstall leaves HRMS-owned schema on shared ERPNext doctypesKeep setup sources and get_customizations() cleanup sources in sync
A workspace is renamed without an upgrade patchExisting sites retain stale public workspaces or linksUpdate the workspace data and add a targeted patch for old site records
Frappe Cloud subscription status cannot be readAccess updates can fail or plan-based behavior can become staleKeep the marketplace request bounded by its timeout and treat hosted-site scope as explicit
A telemetry provider or push service raises an errorA navigation or notification path can appear broken if the error escapesPreserve telemetry guards and the notification error handling
A regional override path does not match the hook keyThe site silently uses the default tax behaviorCheck the decorated function's qualified path against regional_overrides
An employee payment uses a wrong reference amount or exchange rateThe Payment Entry can overpay, underpay, or leave an Employee Advance out of step with the paymentKeep source-document permissions, outstanding calculations, currency conversion, and linked advance updates aligned
Company setup creates defaults for a country but cleanup does not cover themUninstall can leave regional salary or company fixtures on the siteKeep regional setup and uninstall entry points paired and make missing regional modules a no-op
An Employee dashboard or overview reads a source without its permission guardA user can see links or summary data outside the intended Employee access boundaryCheck Employee access first and apply read checks to each related doctype
An Employee overview group changes its response shape or fails the whole requestThe employee view can show wrong values or lose all summary data because one source is unavailableKeep stable group keys and record group errors while returning the other groups
A Holiday List changes without cache invalidationSalary processing can use stale holidays until the cache expiresClear the shared holiday range cache on Holiday List update and deletion

Key files

FileWhy to read it
hrms/hooks.pyCentral map of lifecycle hooks, document events, scheduled work, class overrides, dashboards, routes, assets, and integrations
hrms/setup.pySite setup, default records, permissions, optional app integration, and uninstall cleanup
hrms/install.py and hrms/uninstall.pyUser-facing wrappers around install and uninstall lifecycle calls
hrms/…/desktop.py and hrms/…/utils.pyDesk module registration and app visibility rules
hrms/…/hr_setup.json and hrms/…/payroll.jsonRepresentative setup and payroll workspace navigation and reporting model
hrms/…/company.pyCompany-scoped regional fixtures, payroll accounts, expense account links, validation, and linked-data cleanup
hrms/…/dashboard_overrides.pyCross-doctype dashboard links, dynamic links, and employee attendance view
hrms/…/employee_master.pyEmployee naming, onboarding and recruitment links, approver roles, transfer cleanup, access checks, and attendance timeline data
hrms/…/employee_overview.pyPermission-aware employee pay, attendance, leave, claim, advance, and transaction summary
hrms/…/employee_payment_entry.pyEmployee payment references, outstanding amounts, currency handling, and linked advance exchange rates within the shared Payment Entry flow
hrms/…/holiday_list.pyHoliday assignment resolution across employees, companies, date ranges, and salary cache changes
hrms/subscription_utils.pyHosted subscription checks, employee add-on usage, and ERPNext access changes
hrms/telemetry.py and hrms/…/telemetry.jsBackend business signals and client HR navigation signals
hrms/…/pwa_notifications.py and hrms/…/pwa_notification.pyApproval notification creation, resource refresh, and push delivery boundary
hrms/__init__.pyShared realtime refresh and regional override utilities
hrms/…/__init__.pyShared request context, date range, employee contact, and boot data helpers
hrms/…/delete_old_workspaces.pyExample of upgrade cleanup for old workspace records