frappe-impl-workflow
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "frappe-impl-workflow":https://skillpi.com/zh/skills/deepskill-ed50d561457a260fefd6826ab2d3e6afb91b7076f8a66e875a2d086859538358。安装前核对上游来源和版本:https://github.com/Impertio-Studio/Frappe_Claude_Skill_Package。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
github.com
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
用于在 Frappe 中实现文档工作流、审批链或基于状态的转换,涉及工作流 DocType、工作流状态、工作流操作、转换规则、允许的角色与条件,以及 workflow_state 字段与 apply_workflow 方法,帮助防止因缺少转换或权限错误导致的流程卡住。
介绍来源: third_party · Impertio-Studio · 2.0 参考来源
SkillPi 解读
- 能完成的任务
- 翻译待完成,请参阅来源文档。
- 实测状态
- 未测试
文件浏览
Frontmatter
name: frappe-impl-workflow
description: >
Use when implementing document Workflows, approval chains, or state-based transitions in Frappe.
Prevents stuck documents from missing transitions, broken approval chains, and permission errors on workflow actions.
Covers Workflow DocType, Workflow State, Workflow Action, transition rules, allowed roles, conditions, workflow_state field, apply_workflow.
Keywords: workflow, approval, transition, Workflow State, Workflow Action, state machine, approval chain, workflow_state, approval chain, document approval, multi-step approval, workflow stuck, status transitions..
license: MIT
compatibility: "Claude Code, Claude.ai Projects, Claude API. Frappe v14-v16."
metadata:
author: OpenAEC-Foundation
version: "2.0"Frappe Workflow Implementation
Step-by-step guide for implementing document workflows in Frappe. Covers design, setup, testing, and common approval chain patterns.
Quick Reference: Implementation Checklist
1. □ Design states and transitions on paper/diagram first
2. □ Create Workflow State records (master list)
3. □ Create Workflow Action Master records (Approve, Reject, etc.)
4. □ Create the Workflow DocType record
5. □ Add states with correct doc_status values
6. □ Add transitions with roles, actions, and conditions
7. □ Set allow_edit roles per state
8. □ Configure email notifications (optional)
9. □ Test every transition path with test users
10. □ Verify self-approval blocking works as expected
Step 1: Design Your Workflow
Before touching the UI, map out your workflow on paper.
Identify States
ALWAYS start by listing every distinct document stage:
Example — Purchase Order Approval:
Draft → Pending Review → Pending Approval → Approved → Submitted → Cancelled
Map DocStatus to States
For submittable DocTypes, ALWAYS assign doc_status correctly:
| Stage | doc_status | Meaning |
|---|---|---|
| All "in-progress" states | 0 | Document is Draft, editable |
| Final approved/active state | 1 | Document is Submitted, locked |
| Cancelled state | 2 | Document is Cancelled |
NEVER assign doc_status = 1 to intermediate approval states. A submitted document cannot return to draft. Once submitted, the only forward path is another submitted state or cancellation.
Map Transitions
For each state, define: What actions are possible? Who can perform them? Any conditions?
Draft →[Submit for Review / Creator]→ Pending Review
Pending Review →[Approve / Reviewer]→ Pending Approval
Pending Review →[Reject / Reviewer]→ Draft
Pending Approval →[Approve / Manager]→ Approved
Pending Approval →[Reject / Manager]→ Draft
Approved →[Submit / Manager]→ Submitted (doc_status=1)
Submitted →[Cancel / Manager]→ Cancelled (doc_status=2)
Step 2: Create Prerequisite Records
2a. Create Workflow States
Navigate to Workflow State list or create via API:
# Create states with appropriate styles
states = [
{"workflow_state_name": "Draft", "style": ""},
{"workflow_state_name": "Pending Review", "style": "Primary"},
{"workflow_state_name": "Pending Approval", "style": "Warning"},
{"workflow_state_name": "Approved", "style": "Success"},
{"workflow_state_name": "Submitted", "style": "Info"},
{"workflow_state_name": "Rejected", "style": "Danger"},
{"workflow_state_name": "Cancelled", "style": "Inverse"},
]
for s in states:
if not frappe.db.exists("Workflow State", s["workflow_state_name"]):
frappe.get_doc({"doctype": "Workflow State", **s}).insert()
Available styles: Primary, Success, Warning, Danger, Info, Inverse (or empty for default).
2b. Create Workflow Action Masters
actions = ["Submit for Review", "Approve", "Reject", "Send Back", "Cancel"]
for action in actions:
if not frappe.db.exists("Workflow Action Master", action):
frappe.get_doc({
"doctype": "Workflow Action Master",
"workflow_action_name": action
}).insert()
Step 3: Create the Workflow
Via UI
Navigate to Setup > Workflow > New Workflow:
- Set Workflow Name (e.g., "Purchase Order Approval")
- Set Document Type (e.g., "Purchase Order")
- Check Is Active
- Add states in the States table
- Add transitions in the Transitions table
Via Python
workflow = frappe.get_doc({
"doctype": "Workflow",
"workflow_name": "Purchase Order Approval",
"document_type": "Purchase Order",
"is_active": 1,
"send_email_alert": 1,
"states": [
{"state": "Draft", "doc_status": "0", "allow_edit": "Purchase User"},
{"state": "Pending Approval", "doc_status": "0", "allow_edit": "Purchase Manager"},
{"state": "Approved", "doc_status": "1", "allow_edit": "Purchase Manager"},
{"state": "Rejected", "doc_status": "0", "allow_edit": "Purchase User"},
{"state": "Cancelled", "doc_status": "2"},
],
"transitions": [
{
"state": "Draft",
"action": "Submit for Review",
"next_state": "Pending Approval",
"allowed": "Purchase User",
"allow_self_approval": 1,
},
{
"state": "Pending Approval",
"action": "Approve",
"next_state": "Approved",
"allowed": "Purchase Manager",
"allow_self_approval": 0,
},
{
"state": "Pending Approval",
"action": "Reject",
"next_state": "Rejected",
"allowed": "Purchase Manager",
},
{
"state": "Rejected",
"action": "Submit for Review",
"next_state": "Pending Approval",
"allowed": "Purchase User",
},
{
"state": "Approved",
"action": "Cancel",
"next_state": "Cancelled",
"allowed": "Purchase Manager",
},
],
})
workflow.insert()
Step 4: Configure Advanced Features
Conditional Transitions
Add Python conditions to show transitions only when criteria are met:
# Only allow approval for orders above 50000 by Senior Manager
{
"state": "Pending Approval",
"action": "Approve",
"next_state": "Approved",
"allowed": "Senior Manager",
"condition": "doc.grand_total > 50000",
}
# Standard approval for orders up to 50000
{
"state": "Pending Approval",
"action": "Approve",
"next_state": "Approved",
"allowed": "Purchase Manager",
"condition": "doc.grand_total <= 50000",
}
ALWAYS use doc.fieldname syntax in conditions (the document is exposed as a dict).
Available in conditions: frappe.db.get_value(), frappe.db.get_list(), frappe.session.user, frappe.utils.now_datetime(), frappe.utils.add_to_date(), frappe.utils.get_datetime().
Self-Approval Blocking
Set allow_self_approval = 0 on approval transitions. This means:
- The document owner (creator) CANNOT perform this action
- Administrator is ALWAYS exempt from this restriction
- Other users with the required role CAN perform the action
Email Notifications
- Set
send_email_alert = 1on the Workflow - On each state row, set
send_email = 1(default) - Optionally link an
Email Templatevianext_action_email_template - Add a custom
messageon the state row for inline notification text
Update Fields on State Change
Use update_field and update_value on state rows to automatically set document fields:
# Set approval_status when entering "Approved" state
{"state": "Approved", "doc_status": "1",
"update_field": "approval_status", "update_value": "Approved"}
# Use expression to set approval date dynamically
{"state": "Approved", "doc_status": "1",
"update_field": "custom_approved_on", "update_value": "frappe.utils.now()",
"evaluate_as_expression": 1}
Step 5: Test Your Workflow
Manual Testing Checklist
- Create a test document — verify it starts in the first state (Draft)
- Check available actions — only roles with transitions from Draft should see buttons
- Perform each transition — verify state changes correctly
- Test rejection paths — verify documents return to correct state
- Test self-approval — log in as document owner, verify blocked transitions
- Test conditions — create documents that meet/fail conditions, verify button visibility
- Test email notifications — verify emails sent on state changes
- Test with non-submittable DocType — verify all doc_status = 0
Programmatic Testing
# Get available transitions for a document
from frappe.model.workflow import get_transitions, apply_workflow
doc = frappe.get_doc("Purchase Order", "PO-00001")
transitions = get_transitions(doc)
# Returns list of dicts with action, next_state, allowed, etc.
# Apply a workflow action
updated_doc = apply_workflow(doc, "Approve")
# Returns the updated document after state change
Common Workflow Patterns
Pattern 1: Sequential Approval Chain
Draft → Level 1 Review → Level 2 Review → Approved → Submitted
Each level has its own role. Document moves linearly through approvals.
Pattern 2: Conditional Routing by Amount
Draft → Pending Approval
├─[amount <= 10000 / Team Lead]─→ Approved
├─[amount <= 50000 / Manager]──→ Approved
└─[amount > 50000 / Director]──→ Approved
Use condition on each transition to route based on document values.
Pattern 3: Review with Rejection Loop
Draft ←──[Reject]── Pending Review ──[Approve]──→ Approved
└──[Submit for Review]──→ Pending Review
Rejected documents return to Draft for revision. Creator resubmits. This is the most common approval pattern.
Pattern 4: Leave Approval
Applied (doc_status=0, allow_edit=Employee)
└─[Approve / Leave Approver]─→ Approved (doc_status=1)
└─[Reject / Leave Approver]─→ Rejected (doc_status=0)
Approved
└─[Cancel / HR Manager]─→ Cancelled (doc_status=2)
Pattern 5: Document Review (Non-Submittable)
For non-submittable DocTypes, ALL states MUST have doc_status = 0:
Draft → Under Review → Reviewed → Published
(all doc_status = 0)
Migrating from Manual DocStatus to Workflow
If your DocType currently uses manual Submit/Cancel buttons and you want to add a workflow:
- Map existing documents — The workflow engine auto-maps existing documents to states based on their
docstatuswhen the workflow is created - Define a state for each docstatus — ALWAYS have at least one state per docstatus value your documents currently use
- Test with existing data — Verify that existing submitted documents show the correct workflow state
- Update list views — If using
override_status, the workflow state replaces the Status column
NEVER activate a workflow without a state for docstatus=0. New documents would have no valid initial state.
Decision Tree
Starting a new workflow implementation?
│
├── What type of DocType?
│ ├── Submittable → can use doc_status 0, 1, 2
│ └── Non-submittable → ALL states must be doc_status = 0
│
├── How many approval levels?
│ ├── Single → Two-state: Draft → Approved
│ ├── Sequential → Chain: Draft → L1 → L2 → Approved
│ └── Conditional → Route by field values using conditions
│
├── Need self-approval blocking?
│ └── Set allow_self_approval = 0 on approval transitions
│
├── Need rejection/revision loop?
│ └── Add Reject transition back to Draft or previous state
│
├── Need email notifications?
│ ├── Enable send_email_alert on Workflow
│ └── Link Email Template on each state
│
└── Need automated field updates?
└── Use update_field + update_value on target state
Troubleshooting
| Problem | Cause | Solution |
|---|---|---|
| No action buttons visible | User lacks required role | Add role to user OR add transition for user's role |
| "Self approval is not allowed" | User is doc owner + allow_self_approval=0 |
Have different user approve, or set flag to 1 |
| "Workflow State not set" | Document created before workflow activation | Run update_default_workflow_status or manually set state |
| Document stuck in state | No outgoing transition defined for current state + user role | Add missing transition |
| "Cannot cancel before submitting" | Transition goes from doc_status=0 to doc_status=2 | Add intermediate submitted state |
| Actions show for wrong users | Role assignment too broad | Use more specific roles or add conditions |
See Also
- Workflow Patterns — Detailed step-by-step workflow examples
- Decision Tree — Extended decision tree for workflow design
- Examples — Code examples for common scenarios
- Anti-Patterns — Mistakes to avoid
frappe-core-workflow— Workflow engine internals and API reference
版本历史
-
v3.1.1
GitHub ↗
原版更新说明
## What's new Expanded Keywords in all skill descriptions with user-friendly, non-technical discovery terms. Skills are now easier to find when users describe problems in plain language instead of technical terminology. Examples of added terms: - Symptom-based: "app is slow", "nothing shows", "container won't start" - Beginner-friendly: "how do I start", "what is", "getting started" - Error messages: literal error text users would paste - Alternative names: common synonyms and abbreviations No skill content was changed. Only the Keywords line in SKILL.md frontmatter was expanded.
-
v3.1.0
GitHub ↗
原版更新说明
## What's new - package.json with agents.skills[] manifest for external discovery (60 skills) - agents/openai.yaml for OpenAI Codex - GitHub topic agentskills added - SKILLS_LOG.md added to .gitignore - Em-dashes replaced with colons in 31 SKILL.md section headings Enables discovery via npx skills add, skills.sh, LobeHub, and other platforms.
-
v3.0.0
GitHub ↗
原版更新说明
## Summary - **60 deterministic skills** for Frappe Framework v14-v16 (up from 53 in v2.0) - **~95% surface area coverage** (up from ~85%) - 7 new skills + 12 existing skills extended with new reference files ## New Skills (7) | Skill | Category | Coverage | |-------|----------|----------| | `frappe-core-translation` | core | i18n, _(), __(), CSV/PO files, string extraction | | `frappe-core-utils` | core | 140+ date, number, string, validation functions | | `frappe-syntax-print` | syntax | Print formats, PDF generation, Letter Head | | `frappe-syntax-query-builder` | syntax | frappe.qb, joins, aggregation, cross-DB | | `frappe-impl-workspace` | impl | Workspace builder, number cards, charts | | `frappe-core-logging` | core | frappe.logger(), Error Log, Sentry integration | | `frappe-core-search` | core | Link search, global search, SQLiteSearch FTS5 | ## Extended Skills (12) 13 new reference files added to existing skills covering: Controls API, Tree View, Portal Generators, Print Format decision tree, Email system, Module/Workspace shipping, complete Document API, custom bench commands, request lifecycle, advanced debugging (VS Code DAP), Frappe Packages, data masking (v16+), and Python type stubs. ## Stats | Category | Count | |----------|:-----:| | syntax/ | 13 | | core/ | 11 | | impl/ | 14 | | errors/ | 7 | | ops/ | 8 | | agents/ | 5 | | testing/ | 2 | | **Total** | **60** | ## Install ```bash git clone https://github.com/OpenAEC-Foundation/Frappe_Claude_Skill_Package.git cp -r Frappe_Claude_Skill_Package/skills/source/* ~/.claude/skills/ ```
-
v2.0.0
GitHub ↗
原版更新说明
## Frappe Claude Skill Package v2.0.0 Massive upgrade from 28 ERPNext-specific skills to **53 Frappe Framework skills** covering ~85% of the Frappe surface area. ### What's New - **25 new skills** across 3 new categories (ops, testing, agents) - **28 existing skills** fully rewritten with fresh research - **Renamed** from `erpnext-*` to `frappe-*` (all skills are Frappe Framework, not ERPNext-specific) - **7 categories**: syntax (11), core (7), impl (13), errors (7), ops (8), agents (5), testing (2) ### New Categories - **ops/** — Bench CLI, deployment, backup, performance, upgrades, frontend build, cloud - **testing/** — Unit/integration tests, CI/CD with GitHub Actions - **3 new agents** — debugger, migrator, architect ### Key Improvements - All skills verified against official Frappe docs (March 2026) - v16 features documented: `extend_doctype_class`, data masking, type annotations - MIT license (was LGPL-3.0) - Deterministic language throughout (ALWAYS/NEVER) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
-
v1.1.0
GitHub ↗
原版更新说明
V16 compatibility update and documentation improvements. ## Added - USAGE.md with platform-specific guides (Claude.ai, Claude Code, API) - Complete README overhaul with quick start guide ## Changed - All 28 skills updated for ERPNext/Frappe V16 compatibility - Agent Skills now follow standard skill structure - Improved validation: 28/28 skills pass all checks ## Fixed - V16-specific syntax changes in 9 skills - Agent SKILL.md files now under 500 lines
此处仅展示最近 5 个版本。 在原站查看完整版本历史 ↗
当前收录版本
2.0
安全与评测信息
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- 提供完整的Frappe工作流实现端到端解决方案
- 涵盖从设计到测试的全流程最佳实践
- 包含多种常见审批模式的具体实现示例
待提升项
-
description标点规范 原报告严重程度:轻微
description末尾存在双句号
改进建议:修正description末尾的双句号为一个句号
亮点
- 关键词覆盖全面且精准
- 触发词边界清晰无歧义
待提升项
-
文档长度优化 原报告严重程度:轻微
主文档超过500行建议拆分
改进建议:考虑将详细示例代码或高级主题拆分为独立文件并通过引用链接
亮点
- Phase划分清晰有逻辑
- 包含实用的快速参考清单和决策树
亮点
- 提供完整的Python API调用示例
- 覆盖条件设置、自审批阻止等高级特性
- 包含详细的故障排除表格
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
-
管理员或提升权限
确认确有必要再提升权限;不要关闭防护、绕过证书验证或扩大整个系统的访问权限。
主文档提及 · 第 209 行
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。