一键导入
frappe-fixture-creator
Generate fixture files for Frappe test data and master data. Use when creating test fixtures, setup data, or master data for new sites.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Generate fixture files for Frappe test data and master data. Use when creating test fixtures, setup data, or master data for new sites.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | frappe-fixture-creator |
| description | Generate fixture files for Frappe test data and master data. Use when creating test fixtures, setup data, or master data for new sites. |
Generate fixture JSON files for test data, master data, and initial site configuration in Frappe applications.
These Frappe conventions apply to everything this skill generates, and override any conflicting example below.
bench (never ./env/bin/bench or a full path). Always pass --site <site> explicitly — never run a bare bench migrate / bench run-tests. Run bench start in the background and only if it isn't already running. Don't run discovery commands (which bench, bench --version).apps/<app>/<app>/<module>/doctype/<name>/<name>.json — the app name appears twice (directory + Python package) — with an empty __init__.py alongside. Never mkdir the folder; write the JSON and run bench --site <site> migrate to create the structure. Don't add creation, modified, owner, modified_by, or docstatus as fields — Frappe manages them.frappe.qb.get_query() over raw frappe.db.sql(). Use frappe.db.get_all() for server logic (ignores permissions) and frappe.db.get_list() for user-facing APIs (enforces them). Never use frappe.db.set_value() on a field with validation or lifecycle logic — load the doc and doc.save() so controller hooks run. Batch-fetch related records; never query inside a loop (N+1).frappe.db.commit() in controllers, request handlers, background jobs, or patches — Frappe auto-commits on success and rolls back on uncaught errors. Flush manually only to make a write visible to a subsequent frappe.enqueue() (or pass enqueue_after_commit=True).@frappe.whitelist() parameter so Frappe validates and casts it, and pass methods=[...] to pin the HTTP verb.Claude should invoke this skill when:
Item Fixtures:
[
{
"doctype": "Item",
"item_code": "_Test Item",
"item_name": "Test Item",
"item_group": "Products",
"stock_uom": "Nos",
"is_stock_item": 1,
"is_purchase_item": 1,
"is_sales_item": 1,
"opening_stock": 100,
"valuation_rate": 100,
"standard_rate": 150
},
{
"doctype": "Item",
"item_code": "_Test Service Item",
"item_name": "Test Service",
"item_group": "Services",
"stock_uom": "Nos",
"is_stock_item": 0,
"is_sales_item": 1,
"standard_rate": 500
}
]
Customer Group Tree:
[
{
"doctype": "Customer Group",
"customer_group_name": "All Customer Groups",
"is_group": 1
},
{
"doctype": "Customer Group",
"customer_group_name": "Commercial",
"parent_customer_group": "All Customer Groups",
"is_group": 0
},
{
"doctype": "Customer Group",
"customer_group_name": "Individual",
"parent_customer_group": "All Customer Groups",
"is_group": 0
}
]
Load Fixture in App:
# In app setup
def before_install():
"""Install fixtures before site setup"""
from frappe.core.page.data_import_tool.data_import_tool import import_doc
import_doc('my_app/fixtures/item_groups.json')
import_doc('my_app/fixtures/territories.json')
Declare a fixtures list in the app's hooks.py (apps/<app>/<app>/hooks.py). On bench --site <site> export-fixtures --app <app-name>, Frappe writes each entry's records to apps/<app>/<app>/fixtures/, and reimports them on bench --site <site> migrate / install.
# hooks.py
fixtures = [
"Item Group",
{"dt": "Role", "filters": [["name", "in", ["Expense Manager", "Expense User"]]]},
]
Export:
bench --site <site> export-fixtures --app <app-name>
CRITICAL — always filter Custom Field and Property Setter to your own records. A bare "Custom Field" in fixtures exports EVERY customization on the site, including those owned by other apps and by the user. Filter to the fieldnames your app introduces:
# hooks.py
fixtures = [
{"dt": "Custom Field", "filters": [["fieldname", "in", ["my_field_1", "my_field_2"]]]},
{"dt": "Property Setter", "filters": [["name", "in", ["Sales Invoice-my_field_1-hidden"]]]},
]
To add fields to a DocType owned by another app (e.g. ERPNext's Sales Invoice), never fork its JSON. Add a Custom Field (and a Property Setter to tweak existing properties) from an after_install hook:
# hooks.py
after_install = "my_app.setup.after_install"
# my_app/setup.py
from frappe.custom.doctype.custom_field.custom_field import create_custom_fields
def after_install():
create_custom_fields({
"Sales Invoice": [
{
"fieldname": "my_field_1",
"label": "My Field",
"fieldtype": "Data",
"insert_after": "customer",
},
],
})
Then export those Custom Fields as filtered fixtures (see section 4) so they ship with the app.
frappe-doctype-architect decides — in its reuse/extend plan — when a DocType should be extended with a Custom Field fixture (the section 5 pattern) versus created fresh. Implement fixtures from that plan.Frappe Fixture Patterns:
Plan and design a DocType architecture / data model for a new Frappe feature like a seasoned lead developer — interview the user, map entities, propose DocType names and links, and draw a flowchart of how the doctypes connect. Use this skill when the user says any of "help me plan a doctype architecture", "design a data model for", "what doctypes do I need for", "model a feature", "I want to build <feature>", "I need to implement an evaluation system", "issuing certificates", "design the schema for", "how should I structure my doctypes", "map the entities for", "plan the doctypes for a <X> system" (CRM, helpdesk, ticketing, LMS, booking, approval, subscription, inventory, etc.). It GRILLS the user with staged questions, proposes sensible defaults, keeps a running model, scans the existing app codebase to REUSE or EXTEND existing doctypes (adding fields / Custom Fields) before creating new ones, then produces a Mermaid diagram + per-DocType spec tables and offers to hand off to frappe-doctype-builder to genera
Create custom API endpoints and whitelisted methods for Frappe applications. Use when building REST APIs or custom endpoints.
Generate JavaScript client-side form scripts for Frappe DocTypes. Use when creating form customizations, field validations, custom buttons, or client-side logic for Frappe/ERPNext forms.
Generate data migration scripts for Frappe. Use when migrating data from legacy systems, transforming data structures, or importing large datasets.
Build Frappe DocTypes with fields, permissions, and naming configurations. Use this skill when creating or modifying DocType structures.
Generate API documentation, user guides, and technical documentation for Frappe apps. Use when documenting APIs, creating user guides, or generating OpenAPI specs.