Customization techniques
There are several approaches to customize Frappe apps:- Custom Fields: Add fields to existing DocTypes
- Custom Scripts: Add client-side logic to forms
- Server Scripts: Add server-side logic without code
- Hooks: Override behavior using app hooks
- Custom Apps: Create new apps that extend existing ones
- Fixtures: Export and import customizations
Custom fields
Add fields to standard DocTypes without modifying them:Configure the field
- Select the DocType to customize
- Set Field Name and Label
- Choose Field Type
- Set Insert After to position the field
Programmatic creation
Client scripts
Add JavaScript to forms without modifying files:Configure script
- Select DocType
- Choose Type (Form, List, etc.)
- Write JavaScript in the Script field
Server scripts
Add Python logic without creating files:Configure script
- Select Script Type (DocType Event, API, Permission Query, etc.)
- For DocType events, select the Reference DocType
- Write Python code in the Script field
Using hooks
Hooks allow you to override or extend framework behavior. Define hooks inhooks.py:
Override whitelisted methods
Document events
Hook into document lifecycle:Request hooks
Intercept HTTP requests:Scheduler events
Schedule background tasks:Extending DocType classes
Extend standard DocType controllers with mixins:Fixtures
Export customizations as fixtures for version control:fixtures/ directory that can be imported on other sites.
Property setters
Modify DocType properties without customizing:Custom permissions
Define custom permission logic:Best practices
Use hooks over monkey patching
Use hooks over monkey patching
Prefer documented hooks over directly modifying framework code. Hooks are upgrade-safe.
Create custom apps for major customizations
Create custom apps for major customizations
For significant changes, create a custom app instead of modifying standard apps.
Export fixtures regularly
Export fixtures regularly
Version control your customizations by exporting fixtures after changes.
Document your customizations
Document your customizations
Add comments explaining why customizations were made.
Test thoroughly
Test thoroughly
Test customizations on staging before deploying to production.