frappe-doctype-builder

v2026.04.22

Generate complete Frappe DocType with JSON, Python controller, and JavaScript form scripts.

GitHub
安装命令
npx skhub add vyogotech/frappe-doctype-builder
Markdown
SKILL.md

Generate Frappe DocType

Create complete DocType definitions with proper field types, permissions, controllers, and client scripts.

When to Use

  • Creating new DocTypes
  • Adding fields to existing DocTypes
  • Building master/transaction DocTypes
  • Creating child tables

Core Patterns

1. DocType JSON

{
  "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
    }
  ]
}

2. Field Types

Common: Data, Text, Int, Float, Currency, Date, Datetime, Link, Table, Select, Check Special: HTML, Code, Color, Geolocation, Attach, Attach Image

3. DocType Patterns

Master: track_changes: 1, is_submittable: 0 Transaction: is_submittable: 1, track_changes: 1 Child Table: istable: 1, editable_grid: 1 Settings: issingle: 1

4. Python Controller

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()

5. JavaScript Form Script

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);
    }
});

6. Naming Series

{
  "fieldname": "naming_series",
  "fieldtype": "Select",
  "options": "CUST-.YYYY.-",
  "default": "CUST-.YYYY.-",
  "reqd": 1
}

And in DocType: "autoname": "naming_series:"

Key Patterns

  1. Field naming: snake_case
  2. Labels: Title Case
  3. Required: "reqd": 1
  4. Validation: validate() method
  5. Defaults: before_insert() or field default
  6. Permissions: Role-based in JSON

Best Practices

  • Master data: track_changes: 1
  • Transactions: is_submittable: 1
  • Child tables: istable: 1, editable_grid: 1
  • Validate in controller
  • Client scripts for UX only
  • Least privilege permissions

Remember: This skill is model-invoked. Claude will use it autonomously when detecting DocType development tasks.

发现
标签

此技能尚未发布标签。

版本
最新版本元数据

版本

v2026.04.22

发布时间

2026年4月22日

分类

未分类

许可证

MIT

源路径

frappe-apps-manager/skills/frappe-doctype-builder

默认分支

main

最新提交

4df6911

Tree SHA

b23ed9b