codymaster 4.5.4 → 4.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +46 -1
- package/README.md +86 -31
- package/dist/backends/viking-backend.js +235 -0
- package/dist/backends/viking-http-client.js +176 -0
- package/dist/browse-server.js +251 -0
- package/dist/cli/command-registry.js +26 -0
- package/dist/cli/commands/agent.js +120 -0
- package/dist/cli/commands/dashboard.js +93 -0
- package/dist/cli/commands/design-studio.js +111 -0
- package/dist/cli/commands/distro.js +25 -0
- package/dist/cli/commands/engineering.js +488 -0
- package/dist/cli/commands/project.js +324 -0
- package/dist/cli/commands/skill-chain.js +269 -0
- package/dist/cli/commands/system.js +89 -0
- package/dist/cli/commands/task.js +254 -0
- package/dist/cli/update-check.js +83 -0
- package/dist/cm-config.js +110 -0
- package/dist/cm-suggest.js +77 -0
- package/dist/continuity.js +8 -0
- package/dist/distro-validate.js +54 -0
- package/dist/guardian-core.js +74 -0
- package/dist/index.js +36 -2759
- package/dist/mcp-context-server.js +60 -1
- package/dist/mcp-skills-tools.js +81 -0
- package/dist/retro-summary.js +70 -0
- package/dist/second-opinion-providers.js +79 -0
- package/dist/sprint-pipeline.js +228 -0
- package/dist/storage-backend.js +63 -0
- package/dist/utils/cli-utils.js +76 -0
- package/dist/utils/skill-utils.js +32 -0
- package/install.sh +286 -58
- package/package.json +16 -5
- package/scripts/build-skills.mjs +51 -0
- package/scripts/gate-0-repo-hygiene.js +75 -0
- package/scripts/postinstall.js +56 -1
- package/scripts/security-scan.js +1 -1
- package/scripts/validate-skills.mjs +42 -0
- package/scripts/viking-demo.ts +105 -0
- package/skills/CLAUDE.md +2 -2
- package/skills/_shared/helpers.md +10 -0
- package/skills/cm-ads-tracker/SKILL.md +3 -6
- package/skills/cm-browse/SKILL.md +28 -0
- package/skills/cm-conductor-worktrees/SKILL.md +24 -0
- package/skills/cm-content-factory/SKILL.md +1 -1
- package/skills/cm-content-factory/landing/docs/content/changelog.md +36 -0
- package/skills/cm-content-factory/landing/docs/content/deployment.md +46 -0
- package/skills/cm-content-factory/landing/docs/content/execution-flow.md +67 -0
- package/skills/cm-content-factory/landing/docs/content/openspace.md +27 -0
- package/skills/cm-content-factory/landing/docs/content/openviking.md +33 -0
- package/skills/cm-content-factory/landing/docs/content/use-cases.md +26 -0
- package/skills/cm-content-factory/landing/docs/content/v5-intro.md +28 -0
- package/skills/cm-content-factory/landing/docs/index.html +240 -0
- package/skills/cm-content-factory/landing/index.html +99 -99
- package/skills/cm-content-factory/landing/script.js +42 -0
- package/skills/cm-content-factory/landing/translations.js +400 -400
- package/skills/cm-continuity/SKILL.md +33 -6
- package/skills/cm-design-studio/SKILL.md +30 -0
- package/skills/cm-ecosystem-roadmap/SKILL.md +11 -0
- package/skills/cm-engineering-meta/SKILL.md +69 -0
- package/skills/cm-growth-hacking/SKILL.md +1 -12
- package/skills/cm-guardian-runtime/SKILL.md +22 -0
- package/skills/cm-mcp-engineering/SKILL.md +18 -0
- package/skills/cm-notebooklm/SKILL.md +1 -17
- package/skills/cm-post-deploy-canary/SKILL.md +18 -0
- package/skills/cm-qa-visual-cli/SKILL.md +18 -0
- package/skills/cm-retro-cli/SKILL.md +19 -0
- package/skills/cm-second-opinion-cli/SKILL.md +19 -0
- package/skills/cm-secret-shield/SKILL.md +2 -2
- package/skills/cm-sprint-bus/SKILL.md +29 -0
- package/skills/cm-start/SKILL.md +11 -2
- package/skills/cm-tdd/SKILL.md +61 -74
- package/skills/profiles/README.md +21 -0
- package/skills/profiles/core.txt +23 -0
- package/skills/profiles/design.txt +6 -0
- package/skills/profiles/full.txt +58 -0
- package/skills/profiles/growth.txt +10 -0
- package/skills/profiles/knowledge.txt +7 -0
- package/scripts/test-gemini.js +0 -13
- package/skills/cm-frappe-agent/SKILL.md +0 -134
- package/skills/cm-frappe-agent/agents/doctype-architect.md +0 -596
- package/skills/cm-frappe-agent/agents/erpnext-customizer.md +0 -643
- package/skills/cm-frappe-agent/agents/frappe-backend.md +0 -814
- package/skills/cm-frappe-agent/agents/frappe-custom-frontend.md +0 -557
- package/skills/cm-frappe-agent/agents/frappe-debugger.md +0 -625
- package/skills/cm-frappe-agent/agents/frappe-fixer.md +0 -275
- package/skills/cm-frappe-agent/agents/frappe-frontend.md +0 -660
- package/skills/cm-frappe-agent/agents/frappe-installer.md +0 -158
- package/skills/cm-frappe-agent/agents/frappe-performance.md +0 -307
- package/skills/cm-frappe-agent/agents/frappe-planner.md +0 -419
- package/skills/cm-frappe-agent/agents/frappe-remote-ops.md +0 -153
- package/skills/cm-frappe-agent/agents/github-workflow.md +0 -286
- package/skills/cm-frappe-agent/commands/frappe-app.md +0 -351
- package/skills/cm-frappe-agent/commands/frappe-backend.md +0 -162
- package/skills/cm-frappe-agent/commands/frappe-bench.md +0 -254
- package/skills/cm-frappe-agent/commands/frappe-debug.md +0 -263
- package/skills/cm-frappe-agent/commands/frappe-doctype-create.md +0 -272
- package/skills/cm-frappe-agent/commands/frappe-doctype-field.md +0 -310
- package/skills/cm-frappe-agent/commands/frappe-erpnext.md +0 -210
- package/skills/cm-frappe-agent/commands/frappe-fix.md +0 -59
- package/skills/cm-frappe-agent/commands/frappe-frontend.md +0 -210
- package/skills/cm-frappe-agent/commands/frappe-fullstack.md +0 -243
- package/skills/cm-frappe-agent/commands/frappe-github.md +0 -57
- package/skills/cm-frappe-agent/commands/frappe-install.md +0 -52
- package/skills/cm-frappe-agent/commands/frappe-plan.md +0 -442
- package/skills/cm-frappe-agent/commands/frappe-remote.md +0 -58
- package/skills/cm-frappe-agent/commands/frappe-test.md +0 -356
- package/skills/cm-frappe-agent/docs/README.md +0 -51
- package/skills/cm-frappe-agent/docs/agents-catalog.md +0 -113
- package/skills/cm-frappe-agent/docs/architecture.md +0 -149
- package/skills/cm-frappe-agent/docs/commands-catalog.md +0 -82
- package/skills/cm-frappe-agent/docs/resources-catalog.md +0 -66
- package/skills/cm-frappe-agent/docs/sitemap-urls.txt +0 -52
- package/skills/cm-frappe-agent/docs/sitemap.md +0 -81
- package/skills/cm-frappe-agent/docs/sop/user-guide.md +0 -178
- package/skills/cm-frappe-agent/docs/sop/vibe-coding-guide.md +0 -122
- package/skills/cm-frappe-agent/resources/7-layer-architecture.md +0 -985
- package/skills/cm-frappe-agent/resources/bench_commands.md +0 -73
- package/skills/cm-frappe-agent/resources/code-patterns-guide.md +0 -948
- package/skills/cm-frappe-agent/resources/common_pitfalls.md +0 -266
- package/skills/cm-frappe-agent/resources/doctype-registry.md +0 -158
- package/skills/cm-frappe-agent/resources/installation-guide.md +0 -289
- package/skills/cm-frappe-agent/resources/rest-api-patterns.md +0 -182
- package/skills/cm-frappe-agent/resources/scaffold_checklist.md +0 -82
- package/skills/cm-frappe-agent/resources/upgrade_patterns.md +0 -113
- package/skills/cm-frappe-agent/resources/web-form-patterns.md +0 -252
- package/skills/cm-frappe-agent/skills/bench-commands/SKILL.md +0 -621
- package/skills/cm-frappe-agent/skills/client-scripts/SKILL.md +0 -642
- package/skills/cm-frappe-agent/skills/doctype-patterns/SKILL.md +0 -576
- package/skills/cm-frappe-agent/skills/frappe-api/SKILL.md +0 -740
- package/skills/cm-frappe-agent/skills/remote-operations/SKILL.md +0 -47
- package/skills/cm-frappe-agent/skills/server-scripts/SKILL.md +0 -608
- package/skills/cm-frappe-agent/skills/web-forms/SKILL.md +0 -46
- package/skills/frappe-app-builder.zip +0 -0
|
@@ -1,272 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Create a new Frappe DocType with complete scaffolding including JSON definition, Python controller, JavaScript client script, and tests
|
|
3
|
-
allowed-tools: Bash, Read, Write, Edit, Glob, Grep, TodoWrite
|
|
4
|
-
argument-hint: <doctype_name> [module_name] [--child] [--single] [--submittable]
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Create Frappe DocType
|
|
8
|
-
|
|
9
|
-
You are creating a new DocType in a Frappe application. Follow this systematic process to create a complete, working DocType with all necessary files.
|
|
10
|
-
|
|
11
|
-
## Arguments
|
|
12
|
-
|
|
13
|
-
Parse the user's input: $ARGUMENTS
|
|
14
|
-
|
|
15
|
-
- **doctype_name**: Name of the DocType (e.g., "Project Task", "Customer Feedback")
|
|
16
|
-
- **module_name**: (Optional) Module to create DocType in
|
|
17
|
-
- **--child**: Create as child table (istable=1)
|
|
18
|
-
- **--single**: Create as Single DocType (issingle=1)
|
|
19
|
-
- **--submittable**: Create as submittable document (is_submittable=1)
|
|
20
|
-
|
|
21
|
-
## Process
|
|
22
|
-
|
|
23
|
-
### Step 1: Discover Project Structure
|
|
24
|
-
|
|
25
|
-
1. Find the Frappe app in the current directory:
|
|
26
|
-
```bash
|
|
27
|
-
find . -name "hooks.py" -path "*/apps/*" | head -5
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
2. Read hooks.py to understand the app structure:
|
|
31
|
-
```bash
|
|
32
|
-
cat <app_path>/hooks.py
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
3. Check modules.txt for available modules:
|
|
36
|
-
```bash
|
|
37
|
-
cat <app_path>/modules.txt
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
4. If module not specified, ask user which module to use
|
|
41
|
-
|
|
42
|
-
### Step 2: Create Directory Structure
|
|
43
|
-
|
|
44
|
-
Convert DocType name to directory name:
|
|
45
|
-
- "Project Task" → "project_task"
|
|
46
|
-
- Use snake_case
|
|
47
|
-
|
|
48
|
-
Create the DocType directory:
|
|
49
|
-
```bash
|
|
50
|
-
mkdir -p <app>/<module>/doctype/<doctype_dir>
|
|
51
|
-
touch <app>/<module>/doctype/<doctype_dir>/__init__.py
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
### Step 3: Ask About Fields
|
|
55
|
-
|
|
56
|
-
Ask the user about the fields they want to add. Provide suggestions based on DocType name:
|
|
57
|
-
|
|
58
|
-
- For "Invoice": items table, customer, amounts, dates
|
|
59
|
-
- For "Task": title, description, status, assigned_to, dates
|
|
60
|
-
- For "Settings": configuration fields, checkboxes
|
|
61
|
-
- For child tables: item reference, qty, rate, amount
|
|
62
|
-
|
|
63
|
-
Common field patterns to suggest:
|
|
64
|
-
1. **Status field**: Draft → Active → Completed
|
|
65
|
-
2. **Date range**: start_date, end_date
|
|
66
|
-
3. **Amount fields**: qty, rate, amount, total
|
|
67
|
-
4. **References**: customer, supplier, user links
|
|
68
|
-
|
|
69
|
-
### Step 4: Create DocType JSON
|
|
70
|
-
|
|
71
|
-
Create the JSON file with:
|
|
72
|
-
|
|
73
|
-
```json
|
|
74
|
-
{
|
|
75
|
-
"name": "<DocType Name>",
|
|
76
|
-
"module": "<Module Name>",
|
|
77
|
-
"doctype": "DocType",
|
|
78
|
-
"engine": "InnoDB",
|
|
79
|
-
"field_order": [],
|
|
80
|
-
"fields": [
|
|
81
|
-
// Fields based on user requirements
|
|
82
|
-
],
|
|
83
|
-
"permissions": [
|
|
84
|
-
{
|
|
85
|
-
"role": "System Manager",
|
|
86
|
-
"read": 1,
|
|
87
|
-
"write": 1,
|
|
88
|
-
"create": 1,
|
|
89
|
-
"delete": 1
|
|
90
|
-
}
|
|
91
|
-
],
|
|
92
|
-
"autoname": "naming_series:",
|
|
93
|
-
"naming_rule": "By \"Naming Series\" field",
|
|
94
|
-
"is_submittable": 0,
|
|
95
|
-
"istable": 0,
|
|
96
|
-
"issingle": 0,
|
|
97
|
-
"track_changes": 1,
|
|
98
|
-
"sort_field": "modified",
|
|
99
|
-
"sort_order": "DESC"
|
|
100
|
-
}
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
### Step 5: Create Python Controller
|
|
104
|
-
|
|
105
|
-
```python
|
|
106
|
-
# <doctype>.py
|
|
107
|
-
import frappe
|
|
108
|
-
from frappe import _
|
|
109
|
-
from frappe.model.document import Document
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
class <ClassName>(Document):
|
|
113
|
-
def validate(self):
|
|
114
|
-
pass
|
|
115
|
-
|
|
116
|
-
def before_save(self):
|
|
117
|
-
pass
|
|
118
|
-
|
|
119
|
-
def after_insert(self):
|
|
120
|
-
pass
|
|
121
|
-
|
|
122
|
-
def on_update(self):
|
|
123
|
-
pass
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
Add relevant hooks based on DocType type:
|
|
127
|
-
- For submittable: on_submit, on_cancel
|
|
128
|
-
- For documents with calculations: validate with totals
|
|
129
|
-
- For documents with dates: date validation
|
|
130
|
-
|
|
131
|
-
### Step 6: Create JavaScript Client Script
|
|
132
|
-
|
|
133
|
-
```javascript
|
|
134
|
-
// <doctype>.js
|
|
135
|
-
frappe.ui.form.on('<DocType Name>', {
|
|
136
|
-
refresh: function(frm) {
|
|
137
|
-
// Custom buttons and field toggles
|
|
138
|
-
},
|
|
139
|
-
|
|
140
|
-
validate: function(frm) {
|
|
141
|
-
// Client-side validation
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
Add field handlers for:
|
|
147
|
-
- Link fields that need to fetch data
|
|
148
|
-
- Numeric fields that need calculations
|
|
149
|
-
- Conditional field visibility
|
|
150
|
-
|
|
151
|
-
### Step 7: Create Test File
|
|
152
|
-
|
|
153
|
-
```python
|
|
154
|
-
# test_<doctype>.py
|
|
155
|
-
import frappe
|
|
156
|
-
from frappe.tests.utils import FrappeTestCase
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
class Test<ClassName>(FrappeTestCase):
|
|
160
|
-
def test_create_document(self):
|
|
161
|
-
doc = frappe.get_doc({
|
|
162
|
-
"doctype": "<DocType Name>",
|
|
163
|
-
# Required fields
|
|
164
|
-
})
|
|
165
|
-
doc.insert()
|
|
166
|
-
self.assertTrue(doc.name)
|
|
167
|
-
|
|
168
|
-
def test_validate(self):
|
|
169
|
-
# Test validation logic
|
|
170
|
-
pass
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
### Step 8: Update Module Files
|
|
174
|
-
|
|
175
|
-
If this is a new module, update:
|
|
176
|
-
- modules.txt (add module name)
|
|
177
|
-
- Create module directory structure
|
|
178
|
-
|
|
179
|
-
### Step 9: Migrate
|
|
180
|
-
|
|
181
|
-
Remind user to run migration:
|
|
182
|
-
```bash
|
|
183
|
-
bench --site <sitename> migrate
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
## File Locations
|
|
187
|
-
|
|
188
|
-
```
|
|
189
|
-
<app_name>/
|
|
190
|
-
└── <module_name>/
|
|
191
|
-
└── doctype/
|
|
192
|
-
└── <doctype_name>/
|
|
193
|
-
├── __init__.py
|
|
194
|
-
├── <doctype_name>.json # DocType definition
|
|
195
|
-
├── <doctype_name>.py # Python controller
|
|
196
|
-
├── <doctype_name>.js # Client script
|
|
197
|
-
└── test_<doctype_name>.py # Tests
|
|
198
|
-
```
|
|
199
|
-
|
|
200
|
-
## Field Type Quick Reference
|
|
201
|
-
|
|
202
|
-
| Data | Field Type | Notes |
|
|
203
|
-
|------|------------|-------|
|
|
204
|
-
| Text (short) | Data | Max 140 chars |
|
|
205
|
-
| Text (long) | Text | Unlimited |
|
|
206
|
-
| Number | Int/Float | Use Float for decimals |
|
|
207
|
-
| Money | Currency | Company currency aware |
|
|
208
|
-
| Date | Date/Datetime | |
|
|
209
|
-
| Yes/No | Check | Checkbox |
|
|
210
|
-
| Dropdown | Select | Options separated by \n |
|
|
211
|
-
| Reference | Link | options = DocType name |
|
|
212
|
-
| Child items | Table | options = Child DocType |
|
|
213
|
-
| File | Attach | Single file |
|
|
214
|
-
| Image | Attach Image | With preview |
|
|
215
|
-
|
|
216
|
-
## Common Patterns
|
|
217
|
-
|
|
218
|
-
### Naming Series Field
|
|
219
|
-
```json
|
|
220
|
-
{
|
|
221
|
-
"fieldname": "naming_series",
|
|
222
|
-
"fieldtype": "Select",
|
|
223
|
-
"label": "Series",
|
|
224
|
-
"options": "NEW-.YYYY.-.####",
|
|
225
|
-
"default": "NEW-.YYYY.-.####",
|
|
226
|
-
"reqd": 1
|
|
227
|
-
}
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
### Status Field
|
|
231
|
-
```json
|
|
232
|
-
{
|
|
233
|
-
"fieldname": "status",
|
|
234
|
-
"fieldtype": "Select",
|
|
235
|
-
"label": "Status",
|
|
236
|
-
"options": "\nDraft\nOpen\nClosed\nCancelled",
|
|
237
|
-
"default": "Draft",
|
|
238
|
-
"in_list_view": 1,
|
|
239
|
-
"in_standard_filter": 1
|
|
240
|
-
}
|
|
241
|
-
```
|
|
242
|
-
|
|
243
|
-
### Amount Calculation (in child table)
|
|
244
|
-
```json
|
|
245
|
-
[
|
|
246
|
-
{"fieldname": "item", "fieldtype": "Link", "options": "Item", "in_list_view": 1},
|
|
247
|
-
{"fieldname": "qty", "fieldtype": "Float", "in_list_view": 1},
|
|
248
|
-
{"fieldname": "rate", "fieldtype": "Currency", "in_list_view": 1},
|
|
249
|
-
{"fieldname": "amount", "fieldtype": "Currency", "in_list_view": 1, "read_only": 1}
|
|
250
|
-
]
|
|
251
|
-
```
|
|
252
|
-
|
|
253
|
-
## Output
|
|
254
|
-
|
|
255
|
-
After completion, provide:
|
|
256
|
-
|
|
257
|
-
1. Summary of files created
|
|
258
|
-
2. List of fields added
|
|
259
|
-
3. Next steps:
|
|
260
|
-
- Run `bench --site <site> migrate`
|
|
261
|
-
- Customize form layout in Desk
|
|
262
|
-
- Add more fields as needed
|
|
263
|
-
- Write controller logic
|
|
264
|
-
- Create tests
|
|
265
|
-
|
|
266
|
-
## Important Notes
|
|
267
|
-
|
|
268
|
-
- Use the doctype-architect agent for complex data modeling
|
|
269
|
-
- Use the frappe-backend agent for controller logic
|
|
270
|
-
- Use the frappe-frontend agent for client scripts
|
|
271
|
-
- Always follow Frappe naming conventions
|
|
272
|
-
- Test the migration before proceeding
|
|
@@ -1,310 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Add, modify, or remove fields from an existing Frappe DocType with automatic JSON updates
|
|
3
|
-
allowed-tools: Bash, Read, Write, Edit, Glob, Grep
|
|
4
|
-
argument-hint: <doctype_name> <action> [field_details]
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Manage DocType Fields
|
|
8
|
-
|
|
9
|
-
Add, modify, or remove fields from an existing Frappe DocType. This command helps you update the DocType JSON file correctly.
|
|
10
|
-
|
|
11
|
-
## Arguments
|
|
12
|
-
|
|
13
|
-
Parse the user's input: $ARGUMENTS
|
|
14
|
-
|
|
15
|
-
- **doctype_name**: Name of the existing DocType
|
|
16
|
-
- **action**: add, modify, remove, list
|
|
17
|
-
- **field_details**: Field specifications (for add/modify)
|
|
18
|
-
|
|
19
|
-
## Actions
|
|
20
|
-
|
|
21
|
-
### List Fields
|
|
22
|
-
Show current fields in the DocType:
|
|
23
|
-
```
|
|
24
|
-
/doctype-field "Sales Order" list
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
### Add Field
|
|
28
|
-
Add a new field to the DocType:
|
|
29
|
-
```
|
|
30
|
-
/doctype-field "Sales Order" add customer_reference Data
|
|
31
|
-
/doctype-field "Sales Order" add priority Select "Low\nMedium\nHigh"
|
|
32
|
-
/doctype-field "Sales Order" add items Table "Sales Order Item"
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
### Modify Field
|
|
36
|
-
Modify an existing field:
|
|
37
|
-
```
|
|
38
|
-
/doctype-field "Sales Order" modify customer_name label "Client Name"
|
|
39
|
-
/doctype-field "Sales Order" modify status options "Draft\nActive\nClosed"
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
### Remove Field
|
|
43
|
-
Remove a field (with confirmation):
|
|
44
|
-
```
|
|
45
|
-
/doctype-field "Sales Order" remove customer_reference
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
## Process
|
|
49
|
-
|
|
50
|
-
### Step 1: Find DocType JSON
|
|
51
|
-
|
|
52
|
-
```bash
|
|
53
|
-
# Search for the DocType JSON file
|
|
54
|
-
find . -name "*.json" -path "*/doctype/*" | xargs grep -l '"name": "<DocType Name>"'
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
Or if you know the app:
|
|
58
|
-
```bash
|
|
59
|
-
# Convert DocType name to path
|
|
60
|
-
# "Sales Order" -> sales_order
|
|
61
|
-
cat apps/<app>/<module>/doctype/<doctype_dir>/<doctype_dir>.json
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
### Step 2: Read Current Structure
|
|
65
|
-
|
|
66
|
-
Read and parse the DocType JSON to understand:
|
|
67
|
-
- Current fields and their order
|
|
68
|
-
- Field types and options
|
|
69
|
-
- Existing sections and columns
|
|
70
|
-
|
|
71
|
-
### Step 3: Validate Field Operation
|
|
72
|
-
|
|
73
|
-
For **add**:
|
|
74
|
-
- Check field name doesn't exist
|
|
75
|
-
- Validate field type
|
|
76
|
-
- Suggest appropriate position
|
|
77
|
-
|
|
78
|
-
For **modify**:
|
|
79
|
-
- Verify field exists
|
|
80
|
-
- Validate new property values
|
|
81
|
-
|
|
82
|
-
For **remove**:
|
|
83
|
-
- Check field exists
|
|
84
|
-
- Warn about dependencies
|
|
85
|
-
- Check if field is used in filters, reports, or code
|
|
86
|
-
|
|
87
|
-
### Step 4: Apply Changes
|
|
88
|
-
|
|
89
|
-
Modify the JSON file maintaining proper structure:
|
|
90
|
-
|
|
91
|
-
#### Adding a Field
|
|
92
|
-
|
|
93
|
-
Position options:
|
|
94
|
-
- After a specific field
|
|
95
|
-
- In a specific section
|
|
96
|
-
- At the end
|
|
97
|
-
|
|
98
|
-
```json
|
|
99
|
-
{
|
|
100
|
-
"fieldname": "new_field",
|
|
101
|
-
"fieldtype": "Data",
|
|
102
|
-
"label": "New Field",
|
|
103
|
-
"insert_after": "existing_field"
|
|
104
|
-
}
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
#### Modifying a Field
|
|
108
|
-
|
|
109
|
-
Update only specified properties:
|
|
110
|
-
```json
|
|
111
|
-
{
|
|
112
|
-
"fieldname": "existing_field",
|
|
113
|
-
"label": "New Label",
|
|
114
|
-
"reqd": 1
|
|
115
|
-
}
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
#### Removing a Field
|
|
119
|
-
|
|
120
|
-
Remove from fields array and field_order.
|
|
121
|
-
|
|
122
|
-
### Step 5: Update Related Files
|
|
123
|
-
|
|
124
|
-
After JSON changes:
|
|
125
|
-
|
|
126
|
-
1. **Client Script** - Add/remove field handlers
|
|
127
|
-
2. **Controller** - Update validation/calculations
|
|
128
|
-
3. **Migration Required** - Remind to run migrate
|
|
129
|
-
|
|
130
|
-
## Field Type Reference
|
|
131
|
-
|
|
132
|
-
### Basic Types
|
|
133
|
-
| Type | Usage | Options |
|
|
134
|
-
|------|-------|---------|
|
|
135
|
-
| Data | Short text | - |
|
|
136
|
-
| Text | Long text | - |
|
|
137
|
-
| Select | Dropdown | Options separated by \n |
|
|
138
|
-
| Check | Checkbox | - |
|
|
139
|
-
| Int | Integer | - |
|
|
140
|
-
| Float | Decimal | - |
|
|
141
|
-
| Currency | Money | - |
|
|
142
|
-
| Date | Date only | - |
|
|
143
|
-
| Datetime | Date + time | - |
|
|
144
|
-
|
|
145
|
-
### Link Types
|
|
146
|
-
| Type | Usage | Options |
|
|
147
|
-
|------|-------|---------|
|
|
148
|
-
| Link | Reference | DocType name |
|
|
149
|
-
| Dynamic Link | Polymorphic | Field containing DocType |
|
|
150
|
-
| Table | Child table | Child DocType name |
|
|
151
|
-
| Table MultiSelect | Many-to-many | Link DocType |
|
|
152
|
-
|
|
153
|
-
### Special Types
|
|
154
|
-
| Type | Usage |
|
|
155
|
-
|------|-------|
|
|
156
|
-
| Attach | File upload |
|
|
157
|
-
| Attach Image | Image upload |
|
|
158
|
-
| Section Break | Section divider |
|
|
159
|
-
| Column Break | Column divider |
|
|
160
|
-
| Tab Break | Tab navigation |
|
|
161
|
-
| HTML | Static content |
|
|
162
|
-
|
|
163
|
-
## Field Properties
|
|
164
|
-
|
|
165
|
-
### Display Properties
|
|
166
|
-
```json
|
|
167
|
-
{
|
|
168
|
-
"label": "Field Label",
|
|
169
|
-
"description": "Help text shown below field",
|
|
170
|
-
"bold": 1,
|
|
171
|
-
"hidden": 0,
|
|
172
|
-
"read_only": 0,
|
|
173
|
-
"print_hide": 0
|
|
174
|
-
}
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
### Data Properties
|
|
178
|
-
```json
|
|
179
|
-
{
|
|
180
|
-
"reqd": 1,
|
|
181
|
-
"unique": 0,
|
|
182
|
-
"default": "Default Value",
|
|
183
|
-
"options": "Option1\nOption2",
|
|
184
|
-
"allow_on_submit": 0,
|
|
185
|
-
"no_copy": 0,
|
|
186
|
-
"translatable": 0
|
|
187
|
-
}
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
### Display Control
|
|
191
|
-
```json
|
|
192
|
-
{
|
|
193
|
-
"in_list_view": 1,
|
|
194
|
-
"in_standard_filter": 1,
|
|
195
|
-
"in_global_search": 1,
|
|
196
|
-
"in_preview": 1,
|
|
197
|
-
"allow_in_quick_entry": 1
|
|
198
|
-
}
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
### Conditional Properties
|
|
202
|
-
```json
|
|
203
|
-
{
|
|
204
|
-
"depends_on": "eval:doc.enable_feature",
|
|
205
|
-
"mandatory_depends_on": "eval:doc.status=='Active'",
|
|
206
|
-
"read_only_depends_on": "eval:doc.docstatus==1"
|
|
207
|
-
}
|
|
208
|
-
```
|
|
209
|
-
|
|
210
|
-
### Link Properties
|
|
211
|
-
```json
|
|
212
|
-
{
|
|
213
|
-
"options": "Customer",
|
|
214
|
-
"fetch_from": "customer.customer_name",
|
|
215
|
-
"fetch_if_empty": 1
|
|
216
|
-
}
|
|
217
|
-
```
|
|
218
|
-
|
|
219
|
-
## Common Field Patterns
|
|
220
|
-
|
|
221
|
-
### Status Field
|
|
222
|
-
```json
|
|
223
|
-
{
|
|
224
|
-
"fieldname": "status",
|
|
225
|
-
"fieldtype": "Select",
|
|
226
|
-
"label": "Status",
|
|
227
|
-
"options": "\nDraft\nPending\nApproved\nRejected",
|
|
228
|
-
"default": "Draft",
|
|
229
|
-
"in_list_view": 1,
|
|
230
|
-
"in_standard_filter": 1,
|
|
231
|
-
"read_only": 1
|
|
232
|
-
}
|
|
233
|
-
```
|
|
234
|
-
|
|
235
|
-
### Customer with Fetch
|
|
236
|
-
```json
|
|
237
|
-
[
|
|
238
|
-
{
|
|
239
|
-
"fieldname": "customer",
|
|
240
|
-
"fieldtype": "Link",
|
|
241
|
-
"label": "Customer",
|
|
242
|
-
"options": "Customer",
|
|
243
|
-
"reqd": 1
|
|
244
|
-
},
|
|
245
|
-
{
|
|
246
|
-
"fieldname": "customer_name",
|
|
247
|
-
"fieldtype": "Data",
|
|
248
|
-
"label": "Customer Name",
|
|
249
|
-
"fetch_from": "customer.customer_name",
|
|
250
|
-
"read_only": 1
|
|
251
|
-
}
|
|
252
|
-
]
|
|
253
|
-
```
|
|
254
|
-
|
|
255
|
-
### Date Range
|
|
256
|
-
```json
|
|
257
|
-
[
|
|
258
|
-
{
|
|
259
|
-
"fieldname": "from_date",
|
|
260
|
-
"fieldtype": "Date",
|
|
261
|
-
"label": "From Date",
|
|
262
|
-
"reqd": 1
|
|
263
|
-
},
|
|
264
|
-
{
|
|
265
|
-
"fieldname": "to_date",
|
|
266
|
-
"fieldtype": "Date",
|
|
267
|
-
"label": "To Date",
|
|
268
|
-
"reqd": 1
|
|
269
|
-
}
|
|
270
|
-
]
|
|
271
|
-
```
|
|
272
|
-
|
|
273
|
-
### Amount Calculation
|
|
274
|
-
```json
|
|
275
|
-
[
|
|
276
|
-
{"fieldname": "qty", "fieldtype": "Float", "label": "Qty"},
|
|
277
|
-
{"fieldname": "rate", "fieldtype": "Currency", "label": "Rate"},
|
|
278
|
-
{"fieldname": "amount", "fieldtype": "Currency", "label": "Amount", "read_only": 1}
|
|
279
|
-
]
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
## Post-Change Steps
|
|
283
|
-
|
|
284
|
-
After modifying the DocType JSON:
|
|
285
|
-
|
|
286
|
-
1. **Run Migration**
|
|
287
|
-
```bash
|
|
288
|
-
bench --site <sitename> migrate
|
|
289
|
-
```
|
|
290
|
-
|
|
291
|
-
2. **Clear Cache** (if schema unchanged)
|
|
292
|
-
```bash
|
|
293
|
-
bench --site <sitename> clear-cache
|
|
294
|
-
```
|
|
295
|
-
|
|
296
|
-
3. **Update Controller** (if logic needed)
|
|
297
|
-
- Add validation for new fields
|
|
298
|
-
- Update calculations
|
|
299
|
-
|
|
300
|
-
4. **Update Client Script** (if UI logic needed)
|
|
301
|
-
- Add field change handlers
|
|
302
|
-
- Update visibility conditions
|
|
303
|
-
|
|
304
|
-
## Output
|
|
305
|
-
|
|
306
|
-
Provide:
|
|
307
|
-
1. Summary of changes made
|
|
308
|
-
2. Updated field list
|
|
309
|
-
3. Migration command to run
|
|
310
|
-
4. Any additional code changes needed
|