Managing Tree-Structured Masters
Some master records in ERPNext are organized in a hierarchical tree structure instead of a flat list. A tree structure allows you to create parent and child records, making it easier to organize data, maintain logical relationships, and generate meaningful reports based on the hierarchy.
For example, a company can organize Territories by Country, State, and City, or Item Groups by Product Categories and Subcategories. This structure improves data organization and simplifies reporting, filtering, and access to related records.
Masters That Support Tree Structure
The following masters are commonly maintained as tree-structured records in ERPNext:
- Chart of Accounts
- Chart of Cost Centers
- Customer Group
- Territory
- Sales Person
- Item Group
Although this article uses Territory as an example, the same concepts and workflow apply to all other tree-structured masters.
How Tree-Structured Masters Work
A tree structure consists of two types of records:
- Parent (Group) Node: Used to organize other records. A parent node can contain one or more child records but is generally not selected directly in transactions.
- Child (Leaf) Node: The final level in the hierarchy. Child records are typically selected in transactions and other master records.
For example, a Territory hierarchy may look like this:
- All Territories
- India
- Gujarat
- Maharashtra
- United States
- California
- Texas
- India
In this example, India and United States are parent nodes, while Gujarat, Maharashtra, California, and Texas are child nodes that can be selected in transactions.
How to Create and Manage Tree-Structured Masters
Step 1: Open the Required Master
Navigate to the tree-structured master that you want to manage.
For example:
Selling > Setup > Territory
The master opens in a tree view displaying the complete hierarchy, starting from the root node.
Step 2: Select the Parent Node
Choose the parent record under which you want to create a new entry.
Every tree master begins with a root node (for example, All Territories). Existing parent and child records are displayed beneath this root.
Selecting a parent node allows you to create another parent group or a child record beneath it.
Step 3: Add a New Record
Click Add Child to create a new entry under the selected parent.
While creating the record, provide the following information:
- Name: Enter the name of the new record. This becomes the identifier for the new territory, item group, customer group, or other tree master.
- Group Node: Specify whether the record should function as a parent group or as a selectable child record.
- Yes: Creates a parent (group) node that can contain additional child records.
- No: Creates a leaf (child) node that cannot have children and can be selected in transactions.
Understanding Group Nodes
A Group Node serves only as a container for organizing records. It helps create multiple levels in the hierarchy but is generally not used directly in transactions.
For example:
- India (Group Node)
- Gujarat (Child)
- Rajasthan (Child)
- Punjab (Child)
Here, India is used only to organize states. Sales Orders, Customers, or other documents would typically reference Gujarat, Rajasthan, or Punjab rather than the parent group.
Benefits of Tree-Structured Masters
- Organizes large amounts of master data into a logical hierarchy.
- Simplifies navigation when working with extensive master records.
- Improves reporting by allowing data analysis at both parent and child levels.
- Makes filtering and searching records more efficient.
- Supports multi-level business structures such as regions, departments, product categories, and organizational hierarchies.
- Reduces duplication by grouping related records under common parent nodes.
Common Use Cases
- Creating country, state, and city hierarchies using Territories.
- Organizing products into categories and subcategories using Item Groups.
- Structuring departments or business units using Cost Centers.
- Grouping customers based on business segments using Customer Groups.
- Managing organizational sales hierarchies using Sales Persons.
- Building multi-level accounting structures using the Chart of Accounts.
Important Notes
- Only leaf (child) nodes are generally available for selection in transactions and linked master records.
- Parent (Group) nodes are intended for organizing the hierarchy and may not be selectable in documents.
- You can create multiple levels within the hierarchy by adding child groups beneath existing parent groups.
- The same tree management workflow is used across all tree-structured masters in ERPNext.