frappe-doctype-builder
Generate complete Frappe DocType with JSON, Python controller, and JavaScript form scripts.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Generate complete Frappe DocType with JSON, Python controller, and JavaScript form scripts.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Use when configuring hooks.py — doc_events, scheduler_events, override_whitelisted_methods, override_doctype_class, jinja, boot_session, permission_query_conditions, has_permission, and fixtures. Prevents silent hook failures from wrong paths or missing migrate after scheduler changes. Covers full hooks.py reference beyond document lifecycle events. Keywords: hooks.py, doc_events, scheduler_events, override method, permission query conditions, boot session, fixtures, override_doctype_class, extend_doctype_class.
Use when building or consuming Frappe REST APIs — auto /api/resource CRUD, @frappe.whitelist endpoints, token vs session auth, file uploads, and response handling. Prevents unauthorized exposure from missing permission checks on whitelisted methods. Covers /api/resource, /api/method, token auth, OAuth, file upload, error mapping. Keywords: whitelist API, /api/resource, /api/method, Frappe REST, token auth, api_key api_secret, call Frappe from outside, expand, filters.
Use when reading or writing Frappe data safely — get_doc, get_all, get_list, frappe.db.get_value, parameterized frappe.db.sql, transactions, bulk ops, and performance. Prevents SQL injection and permission leaks from wrong API choice. Covers ORM reads/writes, raw SQL, transactions, bulk_update, N+1 avoidance. Keywords: frappe.db.sql, frappe.get_all, get_value, set_value, bulk update, N+1, db transaction, get_list, SQL injection, parameterized query.
Use when implementing Frappe's permission model — roles, perm levels, user permissions, share, permission_query_conditions, has_permission hooks, and in-code checks. Prevents unauthorized access from missing server-side checks or broken row-level filters. Covers role permissions, field-level perm_level, User Permissions, share, hooks, frappe.has_permission. Keywords: permissions, role, user permission, perm level, restrict rows, frappe.has_permission, field level security, permission query conditions, share, PermissionError.
Use when debugging Frappe errors, using bench console for live inspection, analyzing tracebacks, or reading Frappe log files. Prevents wasted debugging time from ignoring log context, misreading tracebacks, and not using bench console effectively. Covers bench console, frappe.logger, error log DocType, traceback analysis, common error patterns, log file locations, pdb/debugger integration, VS Code DAP, profiling, Frappe Recorder, mariadb diagnostics. Keywords: debug, bench console, traceback, error log, frappe.logger, pdb, debugging, log analysis, inspect, VS Code, DAP, profiling, recorder, mariadb, monitor, ERPNext error, how to debug, find the bug, what went wrong, stack trace, error message..
Use when receiving vague or unclear ERPNext/Frappe development requests that need interpretation. Transforms requirements like 'make invoice auto-calculate' or 'add approval workflow' into concrete technical specifications. Determines which Frappe mechanisms to use and maps to the full 61-skill catalog. Keywords: vague requirement, clarify scope, translate business need, technical spec, implementation plan, what does this mean, unclear requirement, translate to code, how to build this.
| name | frappe-doctype-builder |
| description | Generate complete Frappe DocType with JSON, Python controller, and JavaScript form scripts. |
Create complete DocType definitions with proper field types, permissions, controllers, and client scripts.
{
"doctype": "DocType",
"name": "Customer",
"module": "CRM",
"autoname": "naming_series:",
"title_field": "customer_name",
"track_changes": 1,
"is_submittable": 0,
"fields": [
{
"fieldname": "customer_name",
"label": "Customer Name",
"fieldtype": "Data",
"reqd": 1
},
{
"fieldname": "email_id",
"label": "Email",
"fieldtype": "Data",
"options": "Email"
}
],
"permissions": [
{
"role": "System Manager",
"read": 1,
"write": 1,
"create": 1,
"delete": 1
}
]
}
Common: Data, Text, Int, Float, Currency, Date, Datetime, Link, Table, Select, Check Special: HTML, Code, Color, Geolocation, Attach, Attach Image
Master: track_changes: 1, is_submittable: 0
Transaction: is_submittable: 1, track_changes: 1
Child Table: istable: 1, editable_grid: 1
Settings: issingle: 1
import frappe
from frappe.model.document import Document
class Customer(Document):
def validate(self):
if self.email_id:
frappe.utils.validate_email_address(self.email_id, throw=True)
if self.credit_limit and self.credit_limit < 0:
frappe.throw("Credit Limit cannot be negative")
def before_insert(self):
if not self.customer_type:
self.customer_type = "Company"
def after_insert(self):
self.create_primary_contact()
frappe.ui.form.on('Customer', {
refresh: function(frm) {
if (frm.doc.docstatus === 0) {
frm.add_custom_button(__('Create Quotation'), function() {
frappe.new_doc('Quotation', {'party_name': frm.doc.name});
});
}
},
customer_type: function(frm) {
frm.set_df_property('company_name', 'hidden',
frm.doc.customer_type === 'Individual' ? 1 : 0);
}
});
{
"fieldname": "naming_series",
"fieldtype": "Select",
"options": "CUST-.YYYY.-",
"default": "CUST-.YYYY.-",
"reqd": 1
}
And in DocType: "autoname": "naming_series:"
"reqd": 1validate() methodbefore_insert() or field defaulttrack_changes: 1is_submittable: 1istable: 1, editable_grid: 1Remember: This skill is model-invoked. Claude will use it autonomously when detecting DocType development tasks.
Need to store data?
├─ YES: Need multiple records?
│ ├─ YES: Need submit/cancel workflow?
│ │ ├─ YES → Standard DocType + is_submittable=1
│ │ └─ NO: Need hierarchy/tree?
│ │ ├─ YES → Tree DocType (is_tree=1)
│ │ └─ NO: Embedded in parent?
│ │ ├─ YES → Child DocType (istable=1)
│ │ └─ NO → Standard DocType
│ └─ NO: Single config/settings → Single DocType (issingle=1)
└─ NO: Data from external source → Virtual DocType (is_virtual=1)
| Property | Type | Purpose |
|---|---|---|
name | str | DocType identifier (singular, e.g. "Sales Invoice") |
module | str | App module this DocType belongs to |
is_submittable | bool | Enables Draft → Submitted → Cancelled workflow |
is_tree | bool | Enables NestedSet hierarchy (lft/rgt columns) |
is_virtual | bool | No database table; data from custom backend |
issingle | bool | Single-instance settings document |
istable | bool | Child table DocType (embedded in parent) |
is_calendar_and_gantt | bool | Enables calendar/gantt views |
track_changes | bool | Stores version history on every save |
track_seen | bool | Tracks which users viewed the document |
track_views | bool | Counts total document views |
allow_rename | bool | Permits renaming after creation |
allow_copy | bool | Enables "Duplicate" action |
allow_import | bool | Enables Data Import for this DocType |
naming_rule | str | Naming method selector (see Naming rules below) |
autoname | str | Naming pattern string |
title_field | str | Field used as display title |
search_fields | str | Comma-separated fields for search results |
show_title_field_in_link | bool | Display title instead of name in Link fields |
image_field | str | Field containing image for avatar display |
sort_field | str | Default sort column |
sort_order | str | "ASC" or "DESC" |
default_print_format | str | Print Format name |
max_attachments | int | Attachment limit |
| Fieldtype | Stores | DB Column |
|---|---|---|
| Data | Text up to 140 chars | VARCHAR(140) |
| Link | Reference to another DocType | VARCHAR(140) |
| Dynamic Link | Reference to any DocType | VARCHAR(140) |
| Select | Single choice from options | VARCHAR(140) |
| Table | Child table rows | Separate table |
| Table MultiSelect | Multi-select link rows | Separate table |
| Check | Boolean 0/1 | TINYINT |
| Int | Whole number | INT |
| Float | Decimal (9 places) | DECIMAL |
| Currency | Money value (6 decimals) | DECIMAL |
| Date | Calendar date | DATE |
| Datetime | Date + time | DATETIME |
| Text Editor | Rich text (HTML) | LONGTEXT |
| Attach | File reference | VARCHAR(140) |
| Small Text | Short multi-line text | TEXT |
| Long Text | Unlimited text | LONGTEXT |
Frappe defines 35+ fieldtypes; consult official Frappe fieldtype documentation for the full list.
| Property | Type | Purpose |
|---|---|---|
reqd | bool | Field is mandatory |
unique | bool | Database UNIQUE constraint |
search_index | bool | Database INDEX for faster queries |
in_list_view | bool | Show in list view columns |
in_standard_filter | bool | Show as filter in list view |
in_preview | bool | Show in document preview |
allow_on_submit | bool | Editable after submission |
read_only | bool | Not editable by user |
hidden | bool | Not visible on form |
depends_on | str | Visibility condition (e.g. eval:doc.status=="Active") |
mandatory_depends_on | str | Conditional mandatory |
read_only_depends_on | str | Conditional read-only |
fetch_from | str | Auto-populate from linked doc (e.g. customer.customer_name) |
fetch_if_empty | bool | Only fetch when field is empty |
options | str | Fieldtype-specific (DocType name, select options, etc.) |
default | str | Default value (supports __user, Today, etc.) |
description | str | Help text below field |
collapsible | bool | Section starts collapsed (Section Break only) |
ALWAYS set naming_rule on the DocType. The autoname field holds the pattern.
| naming_rule value | autoname pattern | Example output |
|---|---|---|
| Set by User | (empty) | User types name manually |
| Autoincrement | (empty) | 1, 2, 3 |
| By Fieldname | field:{fieldname} | Value of that field |
| By Naming Series | naming_series: | e.g. INV-2024-00001 (from series field) |
| Expression | PRE-.##### | PRE-00001, PRE-00002 |
| Expression (Old Style) | {prefix}-{YYYY}-{#####} | e.g. INV-2024-00001 |
| Random | hash | Random 10-char string |
| UUID | (empty) | UUID string |
| By Script | (custom) | Controller autoname() decides |
NEVER rely on Autoincrement in production — gaps appear when records are deleted. Prefer Expression or Naming Series.
Child tables: On the parent, use fieldtype Table or Table MultiSelect with options set to the child DocType name. Child rows automatically get parent, parenttype, parentfield, and idx (1-based order). NEVER create a child DocType without istable=1. NEVER put a non–child-table DocType in a Table field’s options.
| Aspect | Table | Table MultiSelect |
|---|---|---|
| UI | Full editable grid with "Add Row" | Tag-style picker, no "Add Row" |
| Child DocType | Full child with many fields | Often one Link field only |
| Use case | Line items, detail rows | Multi-select references |
Single (issingle=1): Data lives in tabSingles as key-value pairs, not a dedicated table per DocType. NEVER expect a list view. ALWAYS use for app-wide configuration (defaults, feature toggles, API keys).
Tree (is_tree=1): Frappe adds lft, rgt, parent_*, old_parent. ALWAYS define parent_field in the DocType JSON. NEVER manually edit lft/rgt; use frappe.utils.nestedset.rebuild_tree() if the tree is corrupted.
Virtual (is_virtual=1): No DB table. Implement persistence and list behavior in the controller (db_insert, load_from_db, db_update, delete, plus get_list / get_count / get_stats as needed). NEVER treat virtual data as normal frappe.db.* rows.
Fields with mask=1 hide sensitive values from users without mask permission at the field’s permlevel. Administrators still see unmasked values.
NEVER modify code between # begin: auto-generated types and # end: auto-generated types (Frappe TypeExporter output).
tab + DocType name.search_index=1 on fields used in frequent filters or get_list calls.in_standard_filter=1 on fields users frequently filter by.allow_on_submit=1 on child table fields that affect totals without recalculating those totals.fetch_if_empty=1 alongside fetch_from unless you intend to overwrite user edits.depends_on with raw Python — use eval:doc.fieldname == "value" syntax.