erpnext-impl-customapp
1
总安装量
1
周安装量
#54013
全站排名
安装命令
npx skills add https://smithery.ai
Agent 安装分布
replit
1
amp
1
opencode
1
kimi-cli
1
github-copilot
1
Skill 文档
ERPNext Custom App – Implementation
This skill helps you determine HOW to build and structure Frappe/ERPNext custom apps. For exact syntax, see erpnext-syntax-customapp.
Version: v14/v15/v16 compatible (differences noted)
Main Decision: What Are You Building?
âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
â WHAT DO YOU WANT TO CREATE? â
âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ¤
â â
â ⺠Completely new Frappe/ERPNext app? â
â ââ⺠See: NEW APP WORKFLOW â
â â
â ⺠Extend existing ERPNext functionality? â
â ââ⺠See: EXTENSION DECISION â
â â
â ⺠Migrate data between fields/DocTypes? â
â ââ⺠See: PATCH vs FIXTURE DECISION â
â â
â ⺠Export configuration for deployment? â
â ââ⺠See: FIXTURE WORKFLOW â
â â
â ⺠Update existing app to newer Frappe version? â
â ââ⺠See: VERSION UPGRADE WORKFLOW â
â â
âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
Decision 1: Do You Need a Custom App?
âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
â DO YOU ACTUALLY NEED A CUSTOM APP? â
âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ¤
â â
â What changes do you need? â
â â
â ⺠Add fields to existing DocType? â
â ââ⺠NO APP NEEDED: Use Custom Field + Property Setter â
â (Can be exported as fixtures from ANY app) â
â â
â ⺠Simple automation/validation? â
â ââ⺠NO APP NEEDED: Server Script or Client Script â
â (Stored in database, no deployment needed) â
â â
â ⺠Complex business logic, new DocTypes, or Python code? â
â ââ⺠YES, CREATE APP: You need controllers, models, and deployment â
â â
â ⺠Integration with external system? â
â ââ⺠USUALLY YES: APIs need whitelisted methods, scheduled sync â
â â
â ⺠Custom reports with complex queries? â
â ââ⺠DEPENDS: Script Report (no app) vs Query Report (app optional) â
â â
âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
Rule: Start with the SIMPLEST solution. Server Scripts + Custom Fields solve 70% of customization needs without a custom app.
Decision 2: Extension Strategy
âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
â HOW TO EXTEND ERPNext? â
âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ¤
â â
â ⺠Add fields to existing DocType (e.g., Sales Invoice)? â
â ââ⺠Custom Field (via UI or fixtures) â
â ââ⺠Property Setter for behavior changes â
â â
â ⺠Modify DocType behavior/logic? â
â ââ⺠v16: Use `extend_doctype_class` hook (PREFERRED) â
â ââ⺠v14/v15: Use `doc_events` hooks in hooks.py â
â â
â ⺠Override Jinja template? â
â ââ⺠Copy template to your app's templates/ folder â
â ââ⺠Register via `jinja.override_template` in hooks.py â
â â
â ⺠Add new DocType related to existing? â
â ââ⺠Create in your app's module â
â ââ⺠Link via Link field or Dynamic Link â
â â
â ⺠Add new workspace/menu items? â
â ââ⺠Create Workspace DocType in your app â
â ââ⺠Or use `standard_portal_menu_items` hook â
â â
âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
See:
references/decision-tree.mdfor detailed extension patterns.
Decision 3: Patch vs Fixture
âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
â SHOULD THIS BE A PATCH OR A FIXTURE? â
âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ¤
â â
â Is it CONFIGURATION that should be the same everywhere? â
â (Custom Fields, Roles, Workflows, Property Setters) â
â ââ⺠USE FIXTURE â
â â
â Is it a ONE-TIME data transformation? â
â (Migrate old field values, cleanup bad data, populate defaults) â
â ââ⺠USE PATCH â
â â
â Does it need to run BEFORE schema changes? â
â (Backup data from field that will be deleted) â
â ââ⺠USE PATCH with [pre_model_sync] â
â â
â Does it need to run AFTER schema changes? â
â (Populate newly added field with calculated values) â
â ââ⺠USE PATCH with [post_model_sync] â
â â
â Is it master data / lookup tables? â
â (Categories, Status options, Configuration records) â
â ââ⺠USE FIXTURE for initial, PATCH for updates â
â â
âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
See:
references/decision-tree.mdfor patch timing flowchart.
Decision 4: Module Organization
âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
â HOW MANY MODULES DO YOU NEED? â
âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ¤
â â
â Small app (1-5 DocTypes, single purpose)? â
â ââ⺠ONE MODULE with app name â
â Example: my_app/my_app/ (module "My App") â
â â
â Medium app (6-15 DocTypes, multiple areas)? â
â ââ⺠2-4 MODULES by functional area â
â Example: core/, settings/, integrations/ â
â â
â Large app (15+ DocTypes, complex domain)? â
â ââ⺠MODULES by business domain â
â Example: inventory/, sales/, purchasing/, settings/ â
â â
â Multi-tenant or vertical solution? â
â ââ⺠Consider MULTIPLE APPS instead â
â Base app + vertical-specific apps â
â â
âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
Rule: Each DocType belongs to EXACTLY one module. Choose module = where would a user look for this DocType?
Quick Implementation Workflows
New App Workflow
1. Create app structure â bench new-app my_app
2. Configure pyproject â Edit pyproject.toml (v15+) or setup.py (v14)
3. Define modules â Edit modules.txt
4. Create DocTypes â bench --site mysite new-doctype MyDocType
5. Write controllers â my_app/doctype/my_doctype/my_doctype.py
6. Configure hooks â hooks.py for integration
7. Export fixtures â bench --site mysite export-fixtures
8. Test installation â bench --site testsite install-app my_app
See:
references/workflows.mdfor detailed steps.
Patch Workflow
1. Plan the migration â What data moves where?
2. Choose timing â [pre_model_sync] or [post_model_sync]
3. Write patch file â myapp/patches/v1_0/description.py
4. Add to patches.txt â Under correct section
5. Test locally â bench --site testsite migrate
6. Handle errors â Add rollback logic if needed
7. Test on copy of prod â ALWAYS before production
See:
references/workflows.mdfor patch patterns.
Fixture Workflow
1. Configure hooks.py â Define fixtures list with filters
2. Make changes via UI â Custom Fields, Property Setters, etc.
3. Export fixtures â bench --site mysite export-fixtures --app my_app
4. Verify JSON files â Check my_app/fixtures/*.json
5. Commit to version control
6. Test import â bench --site newsite migrate
See:
references/workflows.mdfor fixture strategies.
Version-Specific Considerations
| Aspect | v14 | v15 | v16 |
|---|---|---|---|
| Build config | setup.py | pyproject.toml | pyproject.toml |
| DocType extension | doc_events | doc_events | extend_doctype_class preferred |
| Python minimum | 3.10 | 3.10 | 3.11 |
| INI patches | â | â | â |
| Fixtures format | JSON | JSON | JSON |
v16 Breaking Changes
extend_doctype_classhook: Cleaner DocType extension pattern- Data masking: Field-level privacy configuration available
- UUID naming: New naming rule option for DocTypes
- Chrome PDF: wkhtmltopdf deprecated for PDF generation
Critical Implementation Rules
â ALWAYS
- Start with
bench new-app– Never create structure manually - Define
__version__in__init__.py– Build will fail without it - Test patches on database copy – Never run untested patches on production
- Use batch processing – Any patch touching 1000+ records needs batching
- Filter fixtures – Never export all records of a DocType
- Version your patches – Use v1_0, v2_0 directories for organization
â NEVER
- Put frappe/erpnext in pyproject dependencies – They’re not on PyPI
- Include transactional data in fixtures – Only configuration!
- Hardcode site-specific values – Use hooks or settings DocTypes
- Skip
frappe.db.commit()in large patches – Memory will explode - Delete fields without backup patch – Data loss is irreversible
- Modify core ERPNext files – Always use hooks or override patterns
Reference Files
| File | Contents |
|---|---|
references/decision-tree.md |
Complete decision flowcharts |
references/workflows.md |
Step-by-step implementation guides |
references/examples.md |
Complete working examples |
references/anti-patterns.md |
Common mistakes to avoid |
See Also
erpnext-syntax-customapp– Exact syntax referenceerpnext-syntax-hooks– Hooks configurationerpnext-impl-hooks– Hook implementation patternserpnext-database– Database operations for patches