frappe-impl-reports
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "frappe-impl-reports" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-dfcf6be9f78b9a1aaa777364dfc613752bb48b098d9b82df2279ce0de2b44564. Verify the upstream source and version against https://github.com/Impertio-Studio/Frappe_Claude_Skill_Package before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
github.com
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
Guidance for building script reports, query reports, dashboard charts, or number cards in ERPNext. Intended to prevent empty report outputs caused by column definition errors, broken filters, or unoptimized SQL for large datasets. Covers the report builder, script reports (Python and JS), query reports, report filters, dashboard chart DocType, number cards, and report permissions. Keywords: reports, script reports, query reports, dashboards, charts, number cards, filters, columns, execution, get_data, creating reports, custom reports, dashboard charts, empty reports, no data shown.
Introduction source: third_party · Impertio-Studio · 2.0 Reference
SkillPi interpretation
- Tasks
- ALWAYS create via Desk: Report > New > Script Report > set "Is Standard = Yes" in Developer Mode.
- Testing
- Not tested
Browse files
Frontmatter
name: frappe-impl-reports
description: >
Use when building Script Reports, Query Reports, dashboard charts, or Number Cards in ERPNext.
Prevents empty report output from wrong column definitions, broken filters, and unoptimized SQL in large datasets.
Covers Report Builder, Script Report (Python + JS), Query Report, Report filters, dashboard Chart DocType, Number Card, report permissions.
Keywords: report, Script Report, Query Report, dashboard, chart, Number Card, filters, columns, execute, get_data, create report, custom report, dashboard chart, report empty, no data showing..
license: MIT
compatibility: "Claude Code, Claude.ai Projects, Claude API. Frappe v14-v16."
metadata:
author: OpenAEC-Foundation
version: "2.0"Frappe Report Building
Quick Reference
| Report Type | Best For | Access | Files |
|---|---|---|---|
| Query Report | Simple SQL queries | System Manager only | SQL in DocType or .py |
| Script Report | Complex logic, charts | Administrator + Dev Mode | .py + .js |
| Report Builder | End-user ad-hoc reports | Any permitted user | UI only |
| Prepared Report | Large datasets (>100k rows) | Same as source report | Background job |
Decision Tree: Which Report Type?
Need a report?
├─ End user builds it themselves? → Report Builder
├─ Simple SQL with no Python logic? → Query Report
├─ Complex logic / charts / summary? → Script Report
│ └─ Dataset > 100k rows or timeout? → Add prepared_report = True
└─ Real-time KPI on workspace? → Number Card or Dashboard Chart
1. Creating a Script Report
File Structure
my_app/my_module/report/sales_summary/
├── sales_summary.json # Report DocType definition
├── sales_summary.py # Python: execute() function
└── sales_summary.js # JavaScript: filters + config
ALWAYS create via Desk: Report > New > Script Report > set "Is Standard = Yes" in Developer Mode.
Python: The execute() Function
# sales_summary.py
import frappe
from frappe import _
def execute(filters=None):
columns = get_columns()
data = get_data(filters)
chart = get_chart(data)
report_summary = get_summary(data)
return columns, data, None, chart, report_summary
def get_columns():
return [
{"fieldname": "customer", "label": _("Customer"), "fieldtype": "Link",
"options": "Customer", "width": 200},
{"fieldname": "total", "label": _("Total"), "fieldtype": "Currency",
"options": "currency", "width": 120},
{"fieldname": "qty", "label": _("Qty"), "fieldtype": "Int", "width": 80},
{"fieldname": "posting_date", "label": _("Date"), "fieldtype": "Date", "width": 100},
]
def get_data(filters):
conditions = get_conditions(filters)
return frappe.db.sql("""
SELECT
si.customer, SUM(si.grand_total) as total,
SUM(si.total_qty) as qty, si.posting_date
FROM `tabSales Invoice` si
WHERE si.docstatus = 1 {conditions}
GROUP BY si.customer
ORDER BY total DESC
""".format(conditions=conditions), filters, as_dict=True)
def get_conditions(filters):
conditions = ""
if filters.get("from_date"):
conditions += " AND si.posting_date >= %(from_date)s"
if filters.get("to_date"):
conditions += " AND si.posting_date <= %(to_date)s"
if filters.get("company"):
conditions += " AND si.company = %(company)s"
return conditions
Return value order (positional — ALWAYS maintain this order):
| Position | Name | Type | Required |
|---|---|---|---|
| 1 | columns |
list[dict] | YES |
| 2 | data |
list[dict] or list[list] | YES |
| 3 | message |
str or None | NO |
| 4 | chart |
dict or None | NO |
| 5 | report_summary |
list[dict] or None | NO |
| 6 | skip_total_rows |
bool | NO |
JavaScript: Filters
// sales_summary.js
frappe.query_reports["Sales Summary"] = {
filters: [
{
fieldname: "company",
label: __("Company"),
fieldtype: "Link",
options: "Company",
default: frappe.defaults.get_user_default("company"),
reqd: 1
},
{
fieldname: "from_date",
label: __("From Date"),
fieldtype: "Date",
default: frappe.datetime.add_months(frappe.datetime.get_today(), -1),
reqd: 1
},
{
fieldname: "to_date",
label: __("To Date"),
fieldtype: "Date",
default: frappe.datetime.get_today(),
reqd: 1
},
{
fieldname: "customer_group",
label: __("Customer Group"),
fieldtype: "Link",
options: "Customer Group",
depends_on: "eval:doc.company"
}
],
formatter: function(value, row, column, data, default_formatter) {
value = default_formatter(value, row, column, data);
if (column.fieldname === "total" && data.total > 100000) {
value = "<span style='color:green;font-weight:bold'>" + value + "</span>";
}
return value;
}
};
2. Creating a Query Report
Query Reports use raw SQL. ALWAYS use the legacy column format in SQL aliases:
SELECT
`tabWork Order`.name AS "Work Order:Link/Work Order:200",
`tabWork Order`.creation AS "Date:Date:120",
`tabWork Order`.company AS "Company:Link/Company:150",
`tabWork Order`.qty AS "Qty:Int:80",
`tabWork Order`.grand_total AS "Total:Currency:120"
FROM `tabWork Order`
WHERE `tabWork Order`.docstatus = 1
ORDER BY `tabWork Order`.creation DESC
Column format: "Label:Fieldtype/Options:Width"
Use %(filter_name)s for filter variables in WHERE clauses.
3. Adding Charts to Reports
Return a chart dict as the 4th element from execute():
def get_chart(data):
labels = [d.customer for d in data[:10]]
values = [d.total for d in data[:10]]
return {
"data": {
"labels": labels,
"datasets": [{"name": _("Revenue"), "values": values}]
},
"type": "bar", # bar | line | pie | donut | percentage
"colors": ["#7cd6fd"],
"barOptions": {"stacked": False}, # for bar charts
"height": 300
}
Chart types: bar, line, pie, donut, percentage.
For multi-dataset charts (e.g., comparing periods):
"datasets": [
{"name": "2024", "values": [10, 20, 30]},
{"name": "2025", "values": [15, 25, 35]}
]
4. Adding Report Summary
Return a list of summary dicts as the 5th element:
def get_summary(data):
total_revenue = sum(d.total for d in data)
total_qty = sum(d.qty for d in data)
return [
{"value": total_revenue, "label": _("Total Revenue"),
"datatype": "Currency", "currency": "USD",
"indicator": "Green" if total_revenue > 0 else "Red"},
{"value": total_qty, "label": _("Total Qty"),
"datatype": "Int", "indicator": "Blue"},
{"value": len(data), "label": _("Customers"),
"datatype": "Int", "indicator": "Grey"}
]
Indicator colors: Green, Blue, Orange, Red, Grey.
5. Prepared Reports
For reports that timeout on large datasets, add to the .js file:
frappe.query_reports["Heavy Report"] = {
filters: [ /* ... */ ],
prepared_report: true // enables background generation
};
When prepared_report: true, Frappe queues the report via background job. Users see cached results and can regenerate on demand.
6. Number Cards
Three types of Number Cards for workspace dashboards:
| Type | Source | Use Case |
|---|---|---|
| Document Type | DocType aggregate | Count/sum of documents |
| Report | Script/Query Report | KPI from report data |
| Custom | Whitelisted method | Any computed value |
Document Type Number Card
Create via Desk > Number Card. Set DocType, aggregate function (Count/Sum/Avg), and filters.
Report-Based Number Card
Point to an existing report. The card displays the first row's first numeric column.
Custom Method Number Card
# In your app, create a whitelisted method:
@frappe.whitelist()
def get_open_tickets():
count = frappe.db.count("Issue", {"status": "Open"})
return {"value": count, "fieldtype": "Int", "route_options": {"status": "Open"},
"route": ["query-report", "Open Issues"]}
7. Dashboard Charts
Create via Desk > Dashboard Chart or programmatically in fixtures:
# hooks.py
fixtures = [
{"dt": "Dashboard Chart", "filters": [["module", "=", "My Module"]]}
]
Source types: Report, Group By, Custom (whitelisted method).
Group By Chart
{
"chart_name": "Invoices by Status",
"chart_type": "Group By",
"document_type": "Sales Invoice",
"group_by_type": "Count",
"group_by_based_on": "status",
"type": "Donut",
"filters_json": "{\"docstatus\": 1}"
}
8. Building a Dashboard
Dashboards combine multiple charts and Number Cards:
{
"name": "Sales Dashboard",
"module": "Selling",
"charts": [
{"chart": "Monthly Revenue", "width": "Full"},
{"chart": "Invoices by Status", "width": "Half"},
{"chart": "Top Customers", "width": "Half"}
],
"cards": [
{"card": "Total Revenue"},
{"card": "Open Orders"}
]
}
9. Performance Optimization
- ALWAYS add indexes on columns used in WHERE/GROUP BY (
frappe.model.utils.add_index) - ALWAYS use
as_dict=Trueinfrappe.db.sql()— matches column fieldnames - NEVER use
SELECT *— specify exact columns - NEVER load full documents (
frappe.get_doc) inside report loops — use SQL - Use
frappe.qb(query builder) for parameterized queries in v14+ - For reports > 50k rows, ALWAYS enable
prepared_report: true - ALWAYS filter by
docstatusto exclude draft/cancelled documents
10. Common Patterns
Date Range Filter Pattern
if filters.get("from_date") and filters.get("to_date"):
conditions += " AND posting_date BETWEEN %(from_date)s AND %(to_date)s"
Multi-Currency Pattern
{"fieldname": "amount", "label": _("Amount"), "fieldtype": "Currency",
"options": "currency", "width": 120}
# "options": "currency" means use the row's "currency" field for formatting
Group By with Totals Pattern
data = frappe.db.sql("""
SELECT customer, COUNT(*) as count, SUM(grand_total) as total
FROM `tabSales Invoice`
WHERE docstatus = 1 {conditions}
GROUP BY customer WITH ROLLUP
""".format(conditions=conditions), filters, as_dict=True)
See Also
- references/examples.md — Complete report examples
- references/anti-patterns.md — Common mistakes
- references/workflows.md — Step-by-step workflows
frappe-syntax-api— Frappe Python API referencefrappe-core-database— Database query patterns
Version history
-
v3.1.1
GitHub ↗
Original release notes
## 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 ↗
Original release notes
## 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 ↗
Original release notes
## 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 ↗
Original release notes
## 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 ↗
Original release notes
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
Only the five most recent versions are shown. View full version history at the source ↗
Current listing version
2.0
Safety and assessment details
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 提供 ERPNext 报表开发的完整技术方案,覆盖脚本报表、查询报表、仪表板图表等高价值场景
- 包含性能优化建议和常见模式,显著提升开发者实现效率
Highlights
- 关键词覆盖全面且精准,包括报表类型、组件、常见问题等核心术语
- description 位置正确,内容完整无截断
Areas to improve
-
文档过长 Reported severity: Minor
主文档约600行,超过500行推荐长度
Recommendation: 考虑将部分内容拆分到子章节或引用文件中
Highlights
- 结构层次清晰,包含快速参考、决策树、分步实现和代码示例
- frontmatter 完整,包含兼容性信息和元数据
Highlights
- 提供完整可执行的 Python/JS/SQL 代码示例
- 包含大数据集处理方案(prepared_report)和性能优化建议
- 参数使用规范,条件拼接安全
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
-
Administrator or elevated privileges
Elevate only when necessary. Keep protection and certificate validation enabled and avoid broad system access.
Mentioned in main document · lines 22
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.