Introducing a new way to review your PRs.

Read the announcement

frappe / erpnext

Free and Open Source Enterprise Resource Planning (ERP)

View on GitHub

20 documents · Updated Nov 23, 2026

docs / application-lifecycle-and-extensions

Application lifecycle and extension points

ERPNext is a Frappe application that registers its identity, user interface, web behavior, document rules, scheduled work, and integration services through application hooks. Site installation creates the ERP baseline. The setup wizard and later onboarding flow turn country, company, currency, accounting, and team choices into a usable site. These extension points let ERPNext add regional rules and external service support without changing the Frappe framework.

Application registration

The application registration layer tells Frappe what ERPNext is and how it should appear in a site. It connects the application to its assets, Desk entry, setup flow, installation callbacks, boot data, web routes, and document-level behavior through erpnext/hooks.py.

The main registration areas are:

AreaSystem purpose
Application identityNames ERPNext and defines its Desk home and application access check.
Shared assetsMakes ERPNext Desk, website, email, and icon assets available to the site.
UI extensionAdds client behavior to selected DocTypes and pages.
Module navigationPlaces code-only modules inside sidebars that users can navigate.
Tree navigationGives hierarchy views such as Employee, Item Group, and Department a filtered and permission-aware user path.
Lifecycle callbacksRuns ERPNext setup after app installation or removal.
Test lifecyclePrepares the ERPNext baseline before tests run.
Runtime dataAdds ERPNext settings and page information to a user's boot session.
Web and portal behaviorMaps public routes, portal menus, calendars, and website-generated records.
Accounting dimensionsExtends accounting dimension support to the transaction records that need it.
Regional and search behaviorSelects country-specific replacements and the DocTypes used by global search.

The application depends on Frappe 17 and uses the erpnext package as the installable project. This dependency gives ERPNext its site model, document model, session boot, permissions, web serving, and job scheduler. Tree views add a focused UI layer on top of those records: the Employee tree filters by company, opens existing employees for editing, and shows the new-record action only when the user can create employees (erpnext/…/employee_tree.js• L1-37). Company and Department trees follow the same model by showing only records allowed to the caller and by keeping their add-node actions tied to the intended DocType (erpnext/…/company.py• L1172-1204, erpnext/…/department.py• L72-118).

ERPNext keeps several code-only modules out of the main app dock while assigning their records to an existing sidebar. Integrations, utilities, telephony, communication, EDI, bulk transaction, subcontracting, regional, and maintenance records appear under Setup, Manufacturing, Accounts, or Quality Management (erpnext/hooks.py• L25-46). The Setup sidebar groups organization, access, printing, email, data, integration, and system settings into one navigation surface (erpnext/…/setup.json• L1-100, erpnext/…/setup.json• L132-220, erpnext/…/setup.json• L267-340, erpnext/…/setup.json• L403-562). The Home workspace starts the organization onboarding flow and gives Desk users shortcuts and current business measures (erpnext/…/home.json• L12, erpnext/…/home.json• L24-110, erpnext/…/home.json• L112-158).

References: pyproject.toml• L1-10 pyproject.toml• L44-49 erpnext/hooks.py• L1-111 erpnext/hooks.py• L120-160 erpnext/hooks.py• L623-680 erpnext/hooks.py• L696-739 erpnext/…/setup.json• L1-100 erpnext/…/setup.json• L132-220 erpnext/…/setup.json• L267-340 erpnext/…/setup.json• L403-562 erpnext/…/home.json• L12 erpnext/…/home.json• L24-110 erpnext/…/home.json• L112-158 erpnext/…/employee_tree.js• L1-37 erpnext/…/company.py• L1172-1204 erpnext/…/department.py• L72-118 erpnext/…/item_group.js• L4-15 erpnext/…/item_group.js• L128-147

Site installation

Site installation establishes records and settings that the application needs before normal business work can start. The after_install callback creates roles, settings, custom fields, print defaults, role profiles, navigation items, and other shared ERPNext data, then commits the result.

The install phase also prepares boundaries between framework records and ERPNext business data. It links email and communication records to a company so data from one company is not exposed to another. It gives customer and supplier roles portal access without Desk access. App-install and app-uninstall callbacks also coordinate optional CRM data synchronization when the CRM app is added or removed (erpnext/…/install.py• L272-302, erpnext/…/install.py• L364-372, erpnext/…/install.py• L515-528).

Installation also sets the access rules for company-owned addresses. It preserves site changes to existing Address permissions, grants the required read access to Accounts Manager, and limits edits to the company-address field to Accounts Manager and System Manager (erpnext/…/install.py• L57-109, erpnext/…/install.py• L256-263).

Installation is also the baseline for later setup choices. It creates operational roles, default operations, role profiles, and standard navigation. It applies default print formats and enables or hides feature sections according to the installed settings (erpnext/…/install.py• L28-54, erpnext/…/install.py• L121-166, erpnext/…/install.py• L364-385, erpnext/…/install.py• L431-483).

Application upgrades use versioned patches to bring site records and stored values to the current behavior. For example, the v16 migration adds the Batch Split Stock Entry Type when it is not already present, while later patches rename a component-cost valuation label and backfill Service Level Agreement link filters so upgraded sites use the current stock and service rules. The v16 returned-quantity patch also repairs submitted subcontracting receipt rows from their submitted raw-material return entries, then refreshes affected order status values (erpnext/…/recalculate_returned_qty_of_customer_material_returned_in_parts.py• L6-17).

References: erpnext/…/install.py• L20-54 erpnext/…/install.py• L57-109 erpnext/…/install.py• L121-166 erpnext/…/install.py• L256-302 erpnext/…/install.py• L364-385 erpnext/…/install.py• L431-483 erpnext/…/install.py• L515-528 erpnext/…/add_batch_split_stock_entry_type.py• L1-8 erpnext/…/backfill_sla_link_filters_on_custom_field.py• L4-23 erpnext/…/backfill_sla_link_filters_on_docfield.py• L4-22 erpnext/…/rename_component_cost_valuation_type.py• L3-15 erpnext/…/recalculate_returned_qty_of_customer_material_returned_in_parts.py• L6-17

Setup wizard

The setup wizard converts initial site choices into a first working ERPNext company. Its stages install country-aware presets, create the fiscal year and company, set operational defaults, and record the user's setup persona for telemetry.

The setup flow is ordered because later records rely on earlier choices:

  1. Install presets such as groups, transaction types, address templates, units, and country data.
  2. Create the fiscal year and company with the selected country, currency, domain, and chart of accounts.
  3. Set global, stock, selling, buying, delivery, price-list, and optional bank-account defaults.
  4. Record setup persona choices for product telemetry when the site is not an HRMS-only site.

This diagram shows how setup choices move from the wizard into site records and runtime defaults.

flowchart TD
    A[Setup choices] --> B[Country presets]
    B --> C[Company and fiscal year]
    C --> D[Global and module defaults]
    D --> E[Setup persona telemetry]
    D --> F[Ready ERPNext site]

Country data affects more than display text. It can select address templates, tax presets, territories, payment modes, and other starting records. Company data sets the default currency and company context that later boot and transaction logic use. Tax setup uses country data and the selected chart of accounts to create company tax categories and tax templates. A regional setup module can then add local tax settings when one exists (erpnext/…/taxes_setup.py• L12-30, erpnext/…/taxes_setup.py• L88-134). The fixture and defaults stages also create shared operating records, standard buying and selling price lists, units, and module settings. An optional bank account becomes the company's default when the setup input includes one (erpnext/…/install_fixtures.py• L331-366, erpnext/…/install_fixtures.py• L491-587, erpnext/…/defaults_setup.py• L10-57).

After the first wizard, the Home workspace continues organization setup through a module onboarding flow. It starts with inviting users, then guides the System Manager through accounting, selling, buying, stock, manufacturing, projects, assets, and quality areas (erpnext/…/organization_onboarding.json• L1-56, erpnext/…/invite_users.json• L1-20, erpnext/…/complete_accounting_onboarding.json• L1-20).

References: erpnext/hooks.py• L99-106 erpnext/…/setup_wizard.py• L12-48 erpnext/…/setup_wizard.py• L51-94 erpnext/…/install_fixtures.py• L27-39 erpnext/…/install_fixtures.py• L331-366 erpnext/…/install_fixtures.py• L465-554 erpnext/…/defaults_setup.py• L10-57 erpnext/…/taxes_setup.py• L12-30 erpnext/…/taxes_setup.py• L88-134 erpnext/…/country_wise_tax.json• L1-17 erpnext/…/company.py• L1074-1087 erpnext/…/organization_onboarding.json• L1-56 erpnext/…/invite_users.json• L1-20 erpnext/…/complete_accounting_onboarding.json• L1-20 erpnext/…/home.json• L12

Boot-time configuration

Boot-time configuration supplies a logged-in user with the ERPNext context needed by the Desk. The boot hook adds page routes for tree views, company records, party account types, the current fiscal year, and settings that control sales, accounts, stock, and repost behavior.

Boot data links site state to the user's session. The selected company comes from user defaults or global defaults, while company records provide currency, accounting, stock, and country context. The Global Defaults single record stores site-wide company, country, currency, display choices, document naming behavior, and the optional item search index setting. It is controlled by the System Manager (erpnext/…/global_defaults.json• L23-104, erpnext/…/global_defaults.json• L120-140). On update, it copies key values into Frappe defaults and aligns document display properties and POS rounding with the selected settings. It also enables the selected currency when needed (erpnext/…/global_defaults.py• L14-23, erpnext/…/global_defaults.py• L60-129). ERPNext also adds the user's Employee record to boot and session data when one matches the logged-in user. Guest sessions do not receive the logged-in ERPNext settings block.

The item search index is a site-wide performance choice with an operational constraint. It is intended for a single application server because the index lives on that server's disk, and its build runs in the background (erpnext/…/global_defaults.json• L97-103).

References: erpnext/…/boot.py• L12-82 erpnext/…/boot.py• L84-104 erpnext/__init__.py• L10-30 erpnext/…/global_defaults.py• L14-23 erpnext/…/global_defaults.py• L60-129 erpnext/…/global_defaults.json• L23-104 erpnext/…/global_defaults.json• L120-140 erpnext/…/test_global_defaults.py• L13-74 erpnext/…/party_type.py• L32-68

Document event hooks

Document event hooks connect shared business rules to the Frappe document lifecycle. A document event is a named point such as validation, insert, update, submit, cancel, or delete. ERPNext uses these points to enforce company and accounting-period rules, update linked records, apply service rules, and run country-specific transaction behavior.

Hooks can apply to every DocType, a group of DocTypes, or one DocType. The broad rules run first as part of the document contract. Narrow rules then add effects for transactions such as Stock Entry, User, Communication, invoices, and payment records. A rule can be one handler or a list of handlers when several systems must react to the same event (erpnext/hooks.py• L411-487). Regional handlers use the same contract: invoice submit, cancel, deletion, address validation, and purchase invoice validation can add local behavior without replacing the common document path (erpnext/hooks.py• L447-478).

References: erpnext/hooks.py• L411-487

For the full map of runtime hook behavior and its impact on document flows, see Runtime hooks.

Scheduled automation

Scheduled automation runs work outside the user's request. Frappe invokes ERPNext jobs by schedule group, while the hook registration assigns each job to a cadence such as cron, hourly, hourly maintenance, daily maintenance, weekly, or monthly work.

The jobs maintain state that would otherwise become stale. They update statuses, process accounting and stock work, send reminders, refresh scorecards, synchronize selected integrations, and create or post recurring financial results. The schedule is part of the operational contract: a site that does not run its scheduler will keep accepting requests but will not complete this background work.

References: erpnext/hooks.py• L510-579

For the job groups, ownership, and operational flow, see Scheduled automation.

Web routes and portal access

ERPNext exposes Desk routes, public pages, and portal routes. Route rules map readable URLs such as orders, invoices, shipments, addresses, and banking to DocTypes or website pages. Portal menu entries then expose selected routes to customer and supplier roles, while website permission hooks decide which records those users may see (erpnext/hooks.py• L162-260, erpnext/hooks.py• L273-339, erpnext/hooks.py• L373-385).

The web layer also supports generated website records and custom page context. The support page builds a help view from published articles and page-view counts. The appointment page exposes time slots and creates an unverified appointment only when the portal is enabled. The banking page prepares a protected boot payload for a separate banking interface and accepts only Desk users (erpnext/…/index.py• L6-31, erpnext/…/index.py• L34-78, erpnext/…/index.py• L17-43, erpnext/…/index.py• L113-135, erpnext/…/banking.py• L17-42).

The RFQ portal view supports supplier quotation work without exposing the supplier name in its page header. It lists existing supplier quotations and hides the action to make another quotation when one already exists, which prevents duplicate portal submissions.

References: erpnext/hooks.py• L155-180 erpnext/hooks.py• L219-260 erpnext/hooks.py• L273-339 erpnext/hooks.py• L373-385 erpnext/…/rfq.html• L15-20 erpnext/…/rfq.html• L68-87 erpnext/…/index.py• L6-31 erpnext/…/index.py• L34-78 erpnext/…/index.py• L17-43 erpnext/…/index.py• L113-135 erpnext/…/index.py• L9-64 erpnext/…/banking.py• L17-69

Permission boundaries

Permission hooks protect records at more than one level. Desk permissions can add a query condition or reject access to a record, upload permission can control file-related actions, and website permission can limit portal records for a contact. ERPNext uses these hooks to enforce company restrictions on items, customers, and suppliers and to protect customer- or supplier-facing transaction data (erpnext/hooks.py• L347-385).

Tree views are also access boundaries. Company and Department tree reads use permission-aware record access, while their add-node actions keep the requested operation inside the Company or Department DocType. This makes the tree a filtered view of allowed records rather than a separate way around normal permissions (erpnext/…/company.py• L1172-1204, erpnext/…/department.py• L72-118). Company forms apply the same boundary to linked accounts and warehouses by keeping choices inside the current company (erpnext/…/company.js• L35-79).

Item Group defaults use the same company boundary. The group form shows effective Company defaults and lets an Item or Item Group Manager read them only when the user's write role and Company user permission allow that access. Group values seed new Items that have no Item Defaults, while later group edits do not replace values already copied to an Item (erpnext/…/item_group.js• L4-13, erpnext/…/item_group.js• L160-212, erpnext/…/item_group.py• L90-147, erpnext/…/test_item_group.py• L84-127, erpnext/…/test_item_group.py• L133-165).

Customer Groups combine a hierarchy with party and accounting rules. Their validation keeps group names separate from Customer names, permits one credit limit per company, requires a selling price list, and checks that party accounts and their currencies fit the company. A leaf that has customers cannot become a group (erpnext/…/customer_group.py• L38-58, erpnext/…/customer_group.py• L90-99, erpnext/…/test_customer_group.py• L11-72, erpnext/…/test_customer_group.py• L74-107).

Brand defaults are also company-scoped. They provide item-level account, warehouse, and price behavior, but a same-named Item Group cannot supply defaults for an unrelated Brand. Account links must belong to the selected company and match their accounting use (erpnext/…/test_brand.py• L9-34, erpnext/…/test_brand.py• L36-112, erpnext/…/test_brand.py• L114-144).

Party Type choices apply a related accounting boundary. The account type cannot change after ledger entries exist. Account-linked searches first require permission to read the account and then limit party types to the account's type, with Employee retained as a valid exception for receivable and payable accounts (erpnext/…/party_type.py• L24-29, erpnext/…/party_type.py• L32-68).

Form queries provide a smaller selection boundary inside a document. The Driver form limits transporters to supplier records marked as transporters, then selects an address that matches whether the driver has a transporter. A supplier's default address is applied only if the transporter has not changed during the request (erpnext/…/driver.js• L4-41).

Authorization rules add a business approval boundary. They can require an approving user or role when a transaction exceeds a company-specific or global limit. The rule may be based on total value, average discount, customer discount, item discount, or item-group discount (erpnext/…/authorization_rule.py• L51-122, erpnext/…/authorization_control.py• L164-236).

The application also separates portal roles from Desk roles during installation. Customers and suppliers can use portal routes without receiving Desk access. Employee records connect workforce data to login and user-permission setup, while the Employee tree offers creation only when the boot session grants that permission (erpnext/…/install.py• L368-372, erpnext/…/employee.js• L46-95, erpnext/…/employee.py• L165-180, erpnext/…/employee_tree.js• L15-35). Employee status changes also keep linked user access and sales ownership aligned: leaving an employee disables linked Sales Person records when no open work needs them, but keeps those records enabled when follow-up work still depends on them (erpnext/…/employee.py• L205-220, erpnext/…/employee.py• L659-683, erpnext/…/sales_person.py• L91-134).

Transaction deletion has a stronger boundary. The caller must be a System Manager and must have the required company access. The deletion record protects core and system DocTypes, then tracks the company-scoped deletion work as a protected, submitted record (erpnext/…/transaction_deletion_record.py• L25-67, erpnext/…/transaction_deletion_record.py• L161-180, erpnext/…/transaction_deletion_record.json• L171-198). Only one deletion may be queued or running at a time. Per-DocType cache flags stop new saves for records being removed, and the staged work can retry after a failed run while preserving records shared with other companies (erpnext/…/transaction_deletion_record.py• L271-324, erpnext/…/transaction_deletion_record.py• L616-715, erpnext/…/transaction_deletion_record.py• L778-839, erpnext/…/transaction_deletion_record.py• L907-993).

Terms and Conditions are reusable document templates for selling and buying records. A template must be enabled and applicable to the transaction side before ERPNext renders it. Rendering uses a restricted environment and allows record queries only when both the template editor and the current caller can read the record and its fields. Masked and password fields stay outside that shared readable set. This lets teams reuse business terms without making the template renderer a way around normal permissions (erpnext/…/terms_and_conditions.py• L32-56, erpnext/…/terms_and_conditions.py• L59-169).

References: erpnext/hooks.py• L347-385 erpnext/…/item_group.js• L4-13 erpnext/…/item_group.js• L160-212 erpnext/…/item_group.py• L34-75 erpnext/…/item_group.py• L90-147 erpnext/…/test_item_group.py• L84-165 erpnext/…/customer_group.py• L38-112 erpnext/…/test_customer_group.py• L11-107 erpnext/…/test_brand.py• L9-144 erpnext/…/party_type.py• L24-68 erpnext/…/authorization_rule.py• L51-122 erpnext/…/authorization_control.py• L164-250 erpnext/…/company.js• L35-79 erpnext/…/driver.js• L4-41 erpnext/…/employee.js• L29-95 erpnext/…/employee.py• L165-180 erpnext/…/employee.py• L205-220 erpnext/…/employee.py• L659-683 erpnext/…/employee_tree.js• L15-35 erpnext/…/sales_person.py• L91-134 erpnext/…/company.py• L1172-1204 erpnext/…/department.py• L72-118 erpnext/…/transaction_deletion_record.py• L25-67 erpnext/…/transaction_deletion_record.py• L161-180 erpnext/…/transaction_deletion_record.py• L271-324 erpnext/…/transaction_deletion_record.py• L616-715 erpnext/…/transaction_deletion_record.py• L778-839 erpnext/…/transaction_deletion_record.py• L907-993 erpnext/…/transaction_deletion_record.json• L171-198 erpnext/…/test_transaction_deletion_record.py• L407-425 erpnext/…/test_transaction_deletion_record.py• L524-561 erpnext/…/terms_and_conditions.py• L32-56 erpnext/…/terms_and_conditions.py• L59-169 erpnext/…/test_terms_and_conditions.py• L45-89 erpnext/…/test_terms_and_conditions.py• L124-168

Regional extension points

Regional extensions adapt common ERP flows to local tax, address, invoice, and reporting rules. The regional_overrides map selects alternate functions by country, while document events add country-specific validation or submit and cancel actions. The setup wizard supplies the country that makes these rules meaningful for the site.

The current examples include tax calculation and invoice behavior for Italy, the United Arab Emirates, and Saudi Arabia, plus country-specific setup modules and address templates. These extensions keep the common transaction path intact while replacing only the regional decision or adding the local record rule. Other apps can also replace selected shared lookups through named hooks; for example, employee holiday-list selection can be supplied by an HR app instead of the ERPNext default (erpnext/…/employee.py• L602-628).

Italy's e-invoice output maps local customer identity, address, tax, payment, and line data into the national XML format. The regional output also handles invoices whose list price is absent and invoices that include tax in the printed rate, so local invoice data remains valid across the supported pricing cases.

References: erpnext/hooks.py• L447-478 erpnext/hooks.py• L689-702 erpnext/…/utils.py• L14-30 erpnext/…/utils.py• L9-57 erpnext/…/setup.py• L7-54 erpnext/…/e-invoice.xml• L40-47 erpnext/…/e-invoice.xml• L97-123 erpnext/…/e-invoice.xml• L182-219

Integration extension points

Integration services connect ERPNext records and workflows to external systems. Integration settings hold service credentials and choices, connector classes translate ERPNext actions into provider requests, and scheduled hooks can run synchronization without a user request.

Webhook helpers protect inbound requests by checking a provider signature before changing the session user. Provider connectors then handle service-specific work such as link-token creation or transaction retrieval. The Plaid integration is one example: its settings and connector support bank linking and transaction sync, while the scheduler can trigger automatic synchronization.

Currency exchange is another external service boundary. ERPNext first uses valid stored rates, then an inverse or pegged-currency rate when available. If it must call a provider, only a system user can fetch the rate, and the result is cached for later requests. Provider settings define the endpoint, request values, authentication, and response value, while an invalid or unavailable result falls back to a manual Currency Exchange record (erpnext/…/utils.py• L65-96, erpnext/…/utils.py• L121-221). The provider choices and access-key handling are covered by the currency exchange tests (erpnext/…/test_currency_exchange.py• L134-210).

References: erpnext/…/utils.py• L10-47 erpnext/…/plaid_connector.py• L10-21 erpnext/…/plaid_connector.py• L57-88 erpnext/hooks.py• L528-537 erpnext/…/utils.py• L65-96 erpnext/…/utils.py• L121-221 erpnext/…/test_currency_exchange.py• L84-99 erpnext/…/test_currency_exchange.py• L180-210

Extension selection model

ERPNext extension points form a layered path from app registration to a user's result. Installation creates the records that define the site, boot loads the current context, document hooks enforce rules during business actions, and background jobs complete work after the request. Regional overrides and integrations plug into those layers when a country or external service needs a different path.

This diagram shows the relationship between the main lifecycle layers.

flowchart LR
    A[App registration] --> B[Site installation]
    B --> C[Setup wizard]
    C --> D[Boot context]
    D --> E[Desk and portal request]
    E --> F[Document events]
    E --> G[Web routes and permissions]
    F --> H[Regional rules and integrations]
    E --> I[Scheduled automation]
    I --> H

The key design choice is registration by hook rather than direct framework change. A new business rule should attach to the narrowest lifecycle point that owns it. A regional or provider-specific rule should stay behind its country or service boundary so the common ERP flow remains predictable. These layers support the business flows described in Accounting and finance, Sales and commerce, and Inventory and warehouse.

References: erpnext/hooks.py• L25-46 erpnext/hooks.py• L50-126 erpnext/hooks.py• L155-180 erpnext/hooks.py• L410-579 erpnext/hooks.py• L689-730

Change checklist

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

  • When changing hooks.py, check the matching handler contract and the Frappe lifecycle point. A hook can affect every document or only a named group.
  • When changing code-only module ownership, check that each affected module remains reachable through its assigned sidebar and does not regain an empty app-dock entry.
  • When changing the Setup sidebar or Home workspace, keep module links, workspace role access, and onboarding entry points aligned.
  • When changing tree registration or Company and Department tree handlers, keep the tree route, permission-aware record read, and intended add-node DocType aligned.
  • When changing Company form queries or setup master form rules, keep company, fiscal-year, parent-node, and selected-record filters aligned with the fields they constrain.
  • When changing Item Group defaults, keep the company source, permission exception, form display, copied Item values, and no-overwrite behavior aligned.
  • When changing Customer Group validation, keep the nested-set rules, Customer name boundary, company credit limits, party accounts, currencies, and selling price-list contract aligned.
  • When changing Brand defaults, keep company ownership, account type, warehouse ownership, price-list fallback, and Brand-versus-Item-Group lookup boundaries aligned.
  • When changing Party Type validation or search, keep the ledger immutability rule, Account permission check, account-type filter, and Employee exception aligned.
  • When changing the Driver form, keep the transporter flag, address query filter, supplier default address, and callback check aligned so a late response cannot set an address for a different transporter.
  • When changing Employee status or user-link behavior, keep linked User access, Employee roles, User Permissions, rehire handling, and Sales Person follow-up work aligned.
  • When changing Sales Person disable rules, keep customer links and unfinished Sales Order or Delivery Note work in the blocker contract used by both direct edits and employee departure.
  • When changing Authorization Rule or Authorization Control, keep transaction type, approval basis, company scope, threshold, and approving identity aligned.
  • When changing Company or Transaction Deletion Record permissions, keep the request authorization, Company access, protected DocType list, and protected work-record permissions aligned.
  • When changing tree-view behavior, check the boot data and permission contract that supplies its filters and create actions. Keep the route and the target DocType aligned.
  • When changing setup stages or country presets, check the order between presets, company creation, defaults, address templates, tax templates, price lists, bank account creation, and persona capture.
  • When changing setup persona capture, preserve the HRMS-only exclusion and keep telemetry fields aligned with the setup choices.
  • When changing boot data or Global Defaults, check both user defaults and the System Manager-controlled global values. A missing company, currency, or fiscal-year value can change the first Desk experience.
  • When changing Global Defaults update behavior, keep Frappe defaults, selected-currency availability, document display properties, POS profile rounding, and item-search validation aligned.
  • When changing the item search index setting, keep its single-server storage constraint and background build behavior visible to site operators.
  • When changing Terms and Conditions, keep module applicability, transaction validation, restricted rendering, and the intersection of editor and caller permissions aligned.
  • When changing a website route, check its portal menu, reference DocType, and website permission rule as one access contract.
  • When changing the appointment portal, keep the enabled setting, time-zone validation, slot limits, guest verification, and appointment status flow aligned.
  • When changing the banking page, keep Desk-user checks and boot payload handling aligned with the separate banking interface.
  • When changing the RFQ portal view, check both supplier-information visibility and the rule that controls repeat quotation actions.
  • When changing a regional override or country tax setup, check the country key, replacement function contract, source field names, and local output schema.
  • When changing an integration connector, check credential handling, inbound request verification, and any scheduled synchronization entry.
  • When changing currency exchange lookup or provider settings, keep stored-rate precedence, buying and selling direction, stale-rate policy, pegged-currency conversion, system-user access, cache lifetime, and manual fallback aligned.
  • When changing a scheduled job group, check the scheduler cadence and whether the work is safe to retry after a failed run.
  • When changing Item Group setup or its root-merge patch, keep translated roots, the seeded root, child links, and the single-root tree invariant aligned.
  • When adding an upgrade patch, check that it is idempotent and creates or repairs the site data needed by the related feature. For returned quantities, keep the submitted return filter, precision, bulk update, and order-status refresh aligned.
  • When adding a metadata backfill patch, check that it targets only missing values, writes the correct link filter, and clears the affected DocType cache.
  • When renaming a stored selection value, check every DocType that can store the old value so upgraded sites do not keep mixed labels.
  • When changing Transaction Deletion Record processing, keep the single active deletion rule, protected and ignored DocTypes, owning company field, cache locks, staged task order, retry state, and derived stock recalculation aligned.

Important failure modes

TriggerConsequenceGuard
Setup stages run without the required prior company or preset dataDefaults or country records cannot be linked to the new siteKeep the wizard stage order and the company/default input contract aligned.
Setup persona capture runs for an HRMS-only siteERPNext sends persona data that the HRMS app should ownKeep the HRMS-only exclusion in the setup stage.
A portal route is registered without a matching website permission ruleA user may reach a route but see no records or receive an access errorTreat the route, reference DocType, role, and website permission hook as one change.
Guest appointment access skips the enabled, time-zone, or verification checksA site can accept invalid or unverified bookingsKeep portal availability, rate limits, time checks, and signed-link verification in the same flow.
The RFQ portal keeps the quotation action after a quotation existsA supplier can submit duplicate quotations for one requestDerive the action state from the existing quotation links.
A broad document validation hook raises an error for an unrelated DocTypeUnrelated document saves fail across the siteKeep global handlers safe for all DocTypes and narrow business rules to their target group.
A Terms and Conditions template is disabled or marked for the wrong transaction sideA transaction cannot use the selected terms or a saved draft can fail validationValidate template status and module applicability during both transaction use and rendering.
A terms template queries fields that the editor or caller cannot readA template can expose protected data or fail when it rendersUse the restricted renderer and require the shared record and field permission set.
A tree read bypasses normal record permissionsA restricted user can see companies or departments outside their allowed scopeUse permission-aware reads for tree data and keep company filters in the tree contract.
A tree add-node request can choose another DocTypeA tree action can create a record outside the intended hierarchyBind each tree add-node action to its own DocType before insert.
An Item Group form shows Company defaults without the matching permission pathA user can see company settings outside their allowed scope or cannot set valid group defaultsKeep Company read, Item or Item Group write, and User Permission checks aligned.
An Item Group change overwrites values already copied to an ItemExisting item behavior changes without an item-level decisionApply group defaults only to new Items without Item Defaults.
A Customer Group shares a name with a Customer or repeats a company credit limitParty links become ambiguous or group validation accepts conflicting limitsKeep name collision and per-company uniqueness checks in the group validation path.
A Customer Group uses a buying price list or mismatched party-account currenciesCustomer transactions can use the wrong pricing or ledger contextRequire selling-side price lists and matching receivable and advance currencies.
Brand defaults resolve from a same-named Item GroupItems use accounts, warehouses, or prices from the wrong business masterResolve defaults by Brand and company rather than by display-name collision.
A Party Type account type changes after ledger entries existExisting ledger records no longer match the party's account meaningReject account-type changes after a related GL Entry exists.
A Party Type search reads an account without permissionA caller can infer account data or receive choices from an unauthorized accountCheck Account permission before reading its account type and filtering results.
A Driver address response is applied after the transporter changesThe form can show an address for the wrong supplierApply the response only when its transporter still matches the current form value.
An employee leaves while linked sales work remains openDisabling the Sales Person can block follow-up documentsKeep linked customer work and unfinished Sales Order or Delivery Note checks before disabling it.
An authorization rule has no valid approving user or roleA transaction cannot pass the required approval boundaryRequire an approving identity and validate the transaction, basis, company, and threshold together.
A form query omits the current company or fiscal yearA user can select an account, warehouse, or distribution record from the wrong contextKeep linked-record filters tied to the active company or fiscal year.
The scheduler is stopped or a maintenance job failsStatus updates, reminders, sync work, and financial background work become staleMonitor scheduler execution and design scheduled work to tolerate retries.
The item search index is enabled on multiple application serversRequests can read different index copies and return inconsistent search resultsUse the setting only when one application server owns the index file.
A regional override uses the wrong country key or function contractLocal tax or invoice behavior is skipped or fails at runtimeMatch the country name and replacement function signature registered in regional_overrides.
Italian invoice data has no usable unit price or violates the national XML contractE-invoice generation can fail or produce an invalid submissionKeep source field fallbacks and regional output fields aligned with the invoice schema.
An inbound integration request has an invalid signatureUntrusted data could enter the siteVerify the provider signature before processing the request.
A currency exchange request is made by a non-system user or returns an invalid provider valueThe external lookup is rejected or the transaction has no usable rateKeep external fetches restricted to system users, validate positive finite rates, and provide a manual Currency Exchange fallback.
Global Defaults has no usable company or currency valueBoot and setup logic can start with incomplete site contextKeep the single-record defaults complete and restrict changes to the System Manager.
Global Defaults changes do not reach Frappe defaults or dependent document settingsNew requests or forms can use old company, currency, rounding, or print behaviorKeep the update path and its dependent field and POS-profile settings synchronized.
An SLA link-filter backfill updates metadata without clearing the affected DocType cacheUsers can continue to see stale Service Level Agreement choices after the patchClear the cache for each DocType whose field metadata changes.
A valuation-label rename omits one of the affected stock or subcontracting DocTypesSites can show different labels for the same component-cost ruleApply the stored-value rename to every registered target DocType.
A returned-quantity patch includes unsubmitted returns or skips the affected order status refreshSubmitted subcontracting receipt quantities or order state remain wrong after upgradeLimit the repair to submitted matching return entries and refresh each changed parent order.
An unauthorized user requests transaction deletion for a companyThe deletion request is rejected before a protected work record is createdRequire the System Manager role and the company access required by the deletion flow.
Two transaction deletions are queued or a save occurs for a DocType under deletionWork can overlap or new records can enter a set being removedEnforce one queued or running deletion and keep per-DocType cache locks active until cleanup.
A deletion list uses a secondary or ambiguous Company linkRecords from the wrong company can be removed or the request cannot be validatedUse the owning company field when present and reject invalid or ambiguous company fields.
A failed deletion retries without rechecking its saved state or changed metadataA retry can delete the wrong set or start while another task still owns the lockAllow retries only from submitted Failed records and revalidate the list and running-task guards.
A code-only module has no assigned sidebar ownerIts records remain in code but users have no normal navigation path to themMap each code-only module to a visible owning sidebar.
An upgrade skips the Batch Split Stock Entry Type patchBatch split workflows do not have their required stock entry typeMake the versioned patch run once and create the record when absent.
Item Group setup leaves the seeded root below an existing translated rootThe site can have two roots for one item-group treeMerge the seeded root into the existing root when the patch finds that setup shape.

Key files

FileWhy to read it
erpnext/hooks.pyCentral map of application registration, lifecycle hooks, permissions, routes, schedules, regional overrides, and boot extensions.
erpnext/…/setup.jsonShows how setup, organization, access, data, and integration records are grouped into the Setup navigation surface.
erpnext/…/home.jsonShows the Home workspace entry point for organization onboarding and the first Desk summary.
erpnext/…/organization_onboarding.jsonShows the post-wizard onboarding path across users and ERPNext business areas.
erpnext/…/employee_tree.jsIllustrates how an Employee hierarchy view connects company context with record actions and create permission.
erpnext/…/company.pyShows the permission-aware Company tree entry point, company context, and company-scoped setup behavior.
erpnext/…/company.jsShows how the Company form keeps linked accounting and warehouse choices inside the current company.
erpnext/…/item_group.jsShows the Item Group tree entry point, company-default view, and item-default inheritance behavior.
erpnext/…/item_group.pyShows how Item Group defaults are resolved and protected by Company and user permissions.
erpnext/…/test_item_group.pyShows the tree invariants, permission contract, and copy-on-create behavior that protect Item Group defaults.
erpnext/…/customer_group.pyShows how the Customer Group hierarchy validates party accounts, prices, currencies, names, and company limits.
erpnext/…/test_customer_group.pyShows the Customer Group name, hierarchy, price-list, account, and credit-limit guarantees.
erpnext/…/test_brand.pyShows the company-scoped Brand default contract and the boundary between Brand and same-named Item Group records.
erpnext/…/party_type.pyShows the ledger protection and permission-aware account-type filtering for party choices.
erpnext/…/driver.jsShows how a document form filters transporters and keeps a returned default address tied to the selected transporter.
erpnext/…/global_defaults.pyShows how site defaults become Frappe defaults and how changes align dependent document and POS settings.
erpnext/…/test_global_defaults.pyShows the contract for stable cache behavior and dependent print and POS settings.
erpnext/…/global_defaults.jsonDefines the site-wide company, country, currency, display, naming, and item-search defaults used by boot and setup context.
erpnext/…/terms_and_conditions.pyShows how reusable terms stay tied to transaction side and shared read permissions.
erpnext/…/test_terms_and_conditions.pyShows the security and applicability guarantees for terms rendering and transaction use.
erpnext/…/authorization_rule.pyShows the business constraints for approval rules.
erpnext/…/authorization_control.pyShows how transaction totals and discounts are matched to approving users and roles.
erpnext/…/employee.jsShows how an Employee record connects to User creation and company-scoped workforce links.
erpnext/…/employee.pyShows how Employee lifecycle changes align linked users, permissions, reporting structure, and sales ownership.
erpnext/…/sales_person.pyShows how Sales Person disable rules protect customer and unfinished transaction work.
erpnext/…/transaction_deletion_record.pyShows the protected, company-scoped work flow for transaction deletion, cache locks, retries, and derived-state cleanup.
erpnext/…/test_transaction_deletion_record.pyShows the deletion workflow guarantees for retry state, shared records, cache ownership, and company-field validation.
erpnext/…/transaction_deletion_record.jsonDefines the protected work record and its System Manager access.
erpnext/…/install.pyShows what installation adds to a new site, how it sets access defaults, and how app install or removal can affect related apps.
erpnext/…/setup_wizard.pyDefines the high-level order of first-site setup and setup persona capture.
erpnext/…/install_fixtures.pyShows how country presets, company records, and operational defaults become site data.
erpnext/…/defaults_setup.pyShows how the wizard applies global, module, price-list, and optional bank-account defaults.
erpnext/…/taxes_setup.pyShows how country data becomes company tax templates and regional tax settings.
erpnext/…/country_wise_tax.jsonDefines country-specific tax starting data for setup.
erpnext/…/add_batch_split_stock_entry_type.pyIllustrates how an upgrade patch adds a required site record without duplicating it.
erpnext/…/backfill_sla_link_filters_on_custom_field.pyIllustrates how an upgrade patch repairs missing custom-field metadata and refreshes affected DocType caches.
erpnext/…/backfill_sla_link_filters_on_docfield.pyIllustrates how the same metadata repair applies to standard DocType fields.
erpnext/…/rename_component_cost_valuation_type.pyIllustrates how an upgrade patch keeps a stored valuation label consistent across related stock and subcontracting records.
erpnext/…/recalculate_returned_qty_of_customer_material_returned_in_parts.pyIllustrates how an upgrade patch repairs submitted subcontracting return quantities and refreshes parent status.
erpnext/…/merge_seeded_item_group_root.pyShows how setup repairs a duplicate Item Group root while preserving one valid tree.
erpnext/…/boot.pyExplains the ERP context sent to a logged-in session.
erpnext/…/utils.pyExplains stored, inverse, pegged, and provider-backed currency exchange lookup.
erpnext/…/test_currency_exchange.pyShows provider selection, access-key protection, cache refresh, and exchange-rate fallback guarantees.
erpnext/…/utils.pyDefines shared webhook validation and provider endpoint construction.
erpnext/…/plaid_connector.pyIllustrates the boundary between integration settings and an external banking service.
erpnext/…/utils.pyIllustrates a country-specific invoice and tax extension.
erpnext/…/utils.pyIllustrates country-specific tax and reverse-charge behavior.
erpnext/…/e-invoice.xmlIllustrates how a regional extension maps ERPNext invoice data to a national electronic invoice format.
erpnext/…/rfq.htmlIllustrates portal visibility and action rules for supplier quotation work.
erpnext/…/index.pyIllustrates a public website page that builds context from ERPNext records and page-view data.
erpnext/…/index.pyIllustrates a guest booking route with availability and verification boundaries.
erpnext/…/index.pyIllustrates signed-link verification for a public appointment.
erpnext/…/banking.pyIllustrates a web page that exposes a safe session boot payload to a separate interface.