Frappe Development Standards and Guidelines
Table of Contents
- Introduction
- DocType Standards
- Field Standards
- DocType Properties
- Best Practices
- Common Patterns
- Additional Notes
Introduction
This document outlines comprehensive standards and guidelines for developing applications using the Frappe Framework. Following these standards ensures consistency, maintainability, and optimal performance across your applications. Whether you're creating new DocTypes, defining fields, or implementing business logic, these guidelines will help maintain high-quality code standards.
DocType Standards
DocType Naming Rules
Basic Naming Standards
Use Title Case for DocType names
- β
Correct:
Customer Profile,Sales Order,Inventory Item - β Incorrect:
customer_profile,Sales_order,inventoryitem
Why? Title Case makes DocTypes easily distinguishable from fields and provides better readability in the UI.
- β
Correct:
Use clear, descriptive names that indicate the purpose
- β
Correct:
Purchase Invoice,Employee Attendance,Project Task - β Incorrect:
PI,EmpAtt,Task1
Why? Clear names reduce confusion and make the codebase self-documenting.
- β
Correct:
For child DocTypes, append "Item" or a relevant descriptor
- β
Correct:
Sales Order Item,Purchase Invoice Item,Task Checklist Item - β Incorrect:
SalesOrderLine,PurchaseInvoiceDetail,TaskChecks
Why? Consistent naming for child DocTypes makes relationships clear and helps maintain a standard pattern.
- β
Correct:
For activity or transaction logs, append "Log" or "History"
- β
Correct:
Payment Log,Inventory Transaction History,User Activity Log - β Incorrect:
PaymentRecord,InventoryTransactions,UserActions
Why? Clear distinction of log tables helps in data organization and querying.
- β
Correct:
Field Standards
Field Naming Conventions
Use snake_case for all field names
- β
Correct:
first_name,tax_amount,shipping_address - β Incorrect:
firstName,TaxAmount,shipping-address
Why? Consistent with Python naming conventions and database field naming practices.
- β
Correct:
Use descriptive prefixes for boolean fields
- β
Correct:
is_active,has_attachments,can_login - β Incorrect:
active,attachments,login
Why? Boolean field prefixes make code more readable and self-documenting.
- β
Correct:
Use clear relationship indicators for link fields
- β
Correct:
customer_id,parent_category,assigned_to - β Incorrect:
customer,parent,assignee
Why? Clear relationship indicators help in understanding data relationships.
- β
Correct:
Field Property Standards
Mandatory Fields Every DocType should include these basic fields:
- title_field (name to be displayed) - creation_date (automatic) - modified_date (automatic) - owner (automatic) - status (if document follows a workflow)Field Labels
- Use Title Case for labels
- Keep labels concise but clear
- Include units in parentheses if applicable
- β Correct: "Weight (kg)", "Duration (Hours)", "Distance (km)"
- β Incorrect: "Weight in KG", "Duration_Hours", "Distance"
Field Types Choose appropriate field types based on data requirements:
- Data: Short text without formatting - Text Editor: Formatted text content - Link: References to other DocTypes - Select: Predefined options (limit to 10) - Table: Child tables - Code: Code content - JSON: JSON content - Attach: File attachments - Signature: Signature capturesWhy? Using the correct field type ensures data integrity and provides appropriate UI elements.
DocType Properties
Basic Properties
Module Settings
- Choose appropriate module - Set proper naming series - Configure document numberingPermission Settings
- Define role-based permissions - Set user permissions if needed - Configure sharing settingsView Settings
- Configure search fields - Set up quick entry fields - Define default sort field
Advanced Properties
Automation Settings
- Configure workflows (if needed) - Set up auto-repeat (if applicable) - Define track changes settingsIntegration Settings
- Enable API access if needed - Configure webhook settings - Set up email alerts
Best Practices
Documentation
Add comprehensive descriptions to DocTypes
- Purpose of the DocType - Key relationships - Important business rulesField Organization
- Group related fields in sections - Order fields logically - Use tabs for distinct categoriesPerformance Considerations
- Index frequently searched fields - Limit number of mandatory fields - Optimize table fields - Keep child tables focused - Limit fields (aim for < 30 per DocType)
Common Patterns
Status Management
Standard status flow for most DocTypes:
Draft β Active β Inactive β Cancelled
Audit Fields
Always ensure these fields are included for tracking:
- Created By
- Created Date
- Modified By
- Modified Date
- Workflow State (if applicable)
Relationship Fields
Standard fields for organizational structure:
- Company (multi-company setups)
- Branch (multi-branch operations)
- Department (departmental segregation)
- Cost Center (accounting purposes)
Additional Notes
Layout Elements
Adding a Column
- Add row without label - Choose Type β Column Break Purpose: Creates a new column in the form layoutAdding a Section
- Add row without label - Choose Type β Section Break Purpose: Creates a new section with optional collapsible behaviorAdding a Tab
- Add row with descriptive label - Choose Type β Tab Break Purpose: Creates a new tab in the form
Special Model Settings
Track Changes
Check "Track Changes" to: - Enable Git tracking - Allow GitHub pushes - Maintain version historySingle DocType
Check "Is Single" for: - Configuration/Settings DocTypes - System preferences - Single-record DocTypesTree DocType
Check "Is Tree" for: - Hierarchical data structures - Parent-child relationships - Organizational structures
Important Considerations
Field Limitations
- Keep field count under 30 per DocType when possible
- Use child tables for repeating data
- Consider breaking large DocTypes into smaller, related DocTypes
Naming Requirements
- Only label and type are mandatory for fields
- Use meaningful, self-documenting names
- Follow naming conventions consistently
Performance Tips
- Index frequently queried fields
- Use appropriate field types
- Optimize table relationships
- Consider data volume in design decisions
Note: These standards are guidelines. While they should be followed in most cases, there might be situations where deviating from them makes sense. Always document the reasoning behind any deviations.