How to Rename a Module in Frappe (Safely)
Renaming a module in Frappe requires updates in both the UI and the source code to maintain consistency across your app. Follow these steps carefully:
Step 1: Rename the Module from the Desk (UI)
- Go to the Module Def (Module Definition) from the Desk.
- Click the Rename option.
- If prompted, select “Merge with existing” if a module with the new name already exists.
- Confirm the change.
Step 2: Rename the Module Folder in the Source Code
- Navigate to your app’s module folder:
apps/[your_app]/[your_app]/[module_name]
- Rename the folder to the new module name using
snake_case
.
Example:attachments → parent_attachments
Step 3: Update Doctype Definitions
- For each Doctype that was under the old module, navigate to:
apps/[your_app]/[your_app]/[new_module_name]/doctype/[doctype_name]/[doctype_name].json
- Open the
.json
file and locate the"module"
field. - Update the value to the new module name in Title Case.
Example:"module": "Attachments" → "module": "Parent Attachments"
Step 4: Update modules.txt
- Open the
modules.txt
file located at:apps/[your_app]/[your_app]/modules.txt
- Add the new module name (Title Case).
- Remove the old module name to avoid errors like:
Module not found
Notes
After completing the above steps, run the following commands:
bench build
bench clear-cache
bench migrate
If needed, restart your bench:
bench restart
Common Mistakes
Mismatch between folder name (
snake_case
) and"module"
field (Title Case
)Forgetting to update
modules.txt
Not updating all DocTypes under the renamed module