frappe-syntax-reports

构建查询报表、脚本报表与使用报表生成器的简明指南。涵盖查询报表(基于 SQL)、脚本报表(基于 Python)、报表生成器、报表列定义、过滤器与 chart_data 集成;并说明常见导致报表错误的因素如列定义错误、权限缺失或数据格式不正确。包含 frappe.query_report、prepared_report 的用法提示与排查建议。关键词:查询报表、脚本报表、报表生成器、报表列、过滤器、chart_data、prepared_report。

仓库最近推送
GitHub Stars
211
Forks
61
Issues / PRs
4

安装方式

先用 Prompt 核对来源与依赖。也可下载安装包。

用 AI 助手安装

复制提示词,让助手先核对固定版本和依赖。

查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "frappe-syntax-reports":https://skillpi.com/zh/skills/deepskill-a0e4b348be467685ad1c508c59d94e9b8bd3bf93f72d2963e6bd6892a1c9e7d0。安装前核对上游来源和版本:https://github.com/Impertio-Studio/Frappe_Claude_Skill_Package。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。

来源与配置

github.com

配置方式待核实

请查看原始来源中的适用工具、依赖和权限要求。

安装实测待补充

构建查询报表、脚本报表与使用报表生成器的简明指南。涵盖查询报表(基于 SQL)、脚本报表(基于 Python)、报表生成器、报表列定义、过滤器与 chart_data 集成;并说明常见导致报表错误的因素如列定义错误、权限缺失或数据格式不正确。包含 frappe.query_report、prepared_report 的用法提示与排查建议。关键词:查询报表、脚本报表、报表生成器、报表列、过滤器、chart_data、prepared_report。

0 下载

介绍来源: third_party · Impertio-Studio · 2.0 参考来源

SkillPi 解读

能完成的任务
翻译待完成,请参阅来源文档。
实测状态
未测试

文件浏览

在原站浏览文件 ↗

原始 SKILL.md

打开原文 ↗
Frontmatter
name: frappe-syntax-reports
description: >
  Use when building Query Reports, Script Reports, or configuring Report Builder, including chart data integration.
  Prevents report errors from wrong column definitions, missing permissions, and incorrect data formatting.
  Covers Query Report (SQL-based), Script Report (Python-based), Report Builder, report columns definition, filters, chart_data, report permissions, prepared_report.
  Keywords: Query Report, Script Report, Report Builder, report columns, filters, chart_data, frappe.query_report, prepared_report, report columns, how to build report, report not showing data, chart in report..
license: MIT
compatibility: "Claude Code, Claude.ai Projects, Claude API. Frappe v14-v16."
metadata:
  author: OpenAEC-Foundation
  version: "2.0"

Reports: Query, Script & Report Builder

Quick Reference

Report Types at a Glance

Type Code Required Use Case Permission
Report Builder None Simple single-DocType listing with filters, group by Any user
Query Report SQL only Direct SQL queries, legacy column format System Manager
Script Report (Standard) Python + JS Complex logic, charts, summaries, trees Administrator + Developer Mode
Script Report (Custom) Python in UI Quick custom reports without app deployment System Manager

Script Report execute() Return Values

def execute(filters=None):
    columns = [...]   # List of dicts
    data = [...]      # List of dicts or lists
    message = "..."   # Optional: HTML message above report
    chart = {...}     # Optional: chart configuration
    report_summary = [...]  # Optional: summary cards
    skip_total_row = False  # Optional: suppress auto-total
    return columns, data, message, chart, report_summary, skip_total_row

Column Definition (Dict Format)

columns = [
    {
        "fieldname": "customer",
        "label": _("Customer"),
        "fieldtype": "Link",
        "options": "Customer",
        "width": 200
    },
    {
        "fieldname": "amount",
        "label": _("Amount"),
        "fieldtype": "Currency",
        "options": "currency",  # field in row holding currency code
        "width": 120
    }
]

Query Report Column Format (Legacy String)

SELECT
  name as "Sales Order:Link/Sales Order:200",
  customer as "Customer:Link/Customer:180",
  grand_total as "Total:Currency:120",
  transaction_date as "Date:Date:100"
FROM `tabSales Order`
WHERE docstatus = 1

Format: "Label:Fieldtype/Options:Width" — Options only needed for Link, Dynamic Link, Currency.

Filter Definition (JS)

frappe.query_reports["My Report"] = {
    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)
        },
        {
            fieldname: "status",
            label: __("Status"),
            fieldtype: "Select",
            options: "\nDraft\nSubmitted\nCancelled"
        }
    ]
};

Decision Tree: Which Report Type?

Need a report?
├─ Simple list/group of one DocType → Report Builder
│   (no code, UI-only, supports Group By with Count/Sum/Avg)
├─ Direct SQL query, no Python logic needed → Query Report
│   (SQL in Report doc, column format in aliases)
├─ Complex logic, calculations, charts → Script Report (Standard)
│   (Python .py + JS .js files, requires Developer Mode)
└─ Quick one-off with Python but no app deploy → Script Report (Custom)
    (Python in Report doc UI, System Manager can create)
Script Report returns what?
├─ Just data → return columns, data
├─ Data + chart → return columns, data, None, chart
├─ Data + summary → return columns, data, None, None, report_summary
├─ Data + message → return columns, data, message
└─ Everything → return columns, data, message, chart, report_summary, skip_total_row

Supported Fieldtypes for Columns

Fieldtype Options Required Notes
Data No Plain text
Link DocType name Clickable link to document
Dynamic Link Fieldname holding DocType Pair with a column containing DocType
Currency Currency field or code Fieldname in row that holds currency
Float No Decimal number
Int No Integer
Percent No Shows percentage bar
Date No Date display
Datetime No Date + time
Check No Boolean checkbox
Select No Dropdown value
Text No Long text
HTML No Raw HTML rendering

Supported Filter Fieldtypes

Fieldtype Options Behavior
Link DocType name Autocomplete from DocType
Select Newline-separated values Dropdown with fixed options
Date — Date picker
DateRange — Returns [from_date, to_date] list
Check — Boolean toggle
Dynamic Link Fieldname of Link filter Depends on another filter value
Data — Free text input
Int — Numeric input
MultiSelectList DocType name Multiple value selection

Chart Data Format

chart = {
    "data": {
        "labels": ["Jan", "Feb", "Mar", "Apr"],
        "datasets": [
            {"name": _("Revenue"), "values": [100, 200, 150, 300]},
            {"name": _("Expense"), "values": [80, 150, 120, 250]}
        ]
    },
    "type": "bar",        # bar, line, pie, donut, percentage
    "fieldtype": "Currency",
    "options": "currency",
    "currency": "USD",
    "colors": ["#5e64ff", "#ffa00a"]  # Optional custom colors
}

Report Summary Format

report_summary = [
    {
        "value": total_revenue,
        "label": _("Total Revenue"),
        "datatype": "Currency",
        "currency": "USD",
        "indicator": "Green"   # Green, Blue, Orange, Red
    },
    {
        "value": total_count,
        "label": _("Total Orders"),
        "datatype": "Int",
        "indicator": "Blue"
    }
]

Prepared Reports

For reports processing large datasets, enable Prepared Report to run asynchronously:

  1. Set prepared_report = 1 in the Report document
  2. User clicks "Generate New Report" — runs in background via enqueue()
  3. Results stored in file; user downloads or views when ready
  4. ALWAYS use for reports that query > 100k rows or take > 30 seconds

Number Cards

Source Type Required Fields How It Works
Document Type document_type, function, aggregate_function_based_on SQL aggregate on DocType
Report report_name, report_field, function Pulls value from a report column
Custom Method method Calls a whitelisted Python method

Custom method signature:

@frappe.whitelist()
def get_total_active_users(filters=None):
    return frappe.db.count("User", {"enabled": 1})

Dashboard Charts

Source Configuration Data Format
Report Set chart_type = "Report", select report Uses report's chart data
Custom Set chart_type = "Custom", define source Hook returns {"labels": [...], "datasets": [...]}
Group By Set chart_type = "Group By", pick field Auto-aggregates by field

Dashboard Chart Source hook in hooks.py:

dashboard_chart_source = [
    "myapp.dashboard_chart_source.get_chart_data"
]

Critical Rules

  • ALWAYS define columns as list of dicts with fieldname, label, fieldtype. The legacy string format is ONLY for Query Report SQL aliases.
  • NEVER return None for columns or data in execute() — ALWAYS return empty lists [].
  • ALWAYS use _(...) for translatable labels in columns and report_summary.
  • NEVER use frappe.db.sql with user-supplied filter values directly in f-strings — ALWAYS pass as parameters: frappe.db.sql(query, filters, as_dict=True).
  • ALWAYS set Reference DocType on the Report document — it controls user access permissions.
  • NEVER omit width in column definitions — columns without width render poorly.
  • ALWAYS match datasets[].values length to labels length in chart data — mismatched lengths cause chart rendering errors.

See Also

版本历史

  1. 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.

  2. 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.

  3. 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/ ```

  4. 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)

  5. 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 实验室的评测报告。

场景价值92/100

亮点

  • 提供 Frappe 报表开发的完整语法参考,涵盖 Query Report、Script Report、Report Builder 三大类型
  • 包含图表数据集成、权限控制、Prepared Report 等高阶功能指导
  • 针对常见错误(列定义、数据格式、权限缺失)提供预防性建议
触发精准95/100

亮点

  • 关键词覆盖全面且精准:'查询报表'、'脚本报表'、'报表生成器'、'chart_data'、'prepared_report' 等均有效命中
  • 支持多种变体表达(如 '如何构建报表'、'报表不显示数据')提升召回率
结构规范90/100

待提升项

  • 缺少显式 When to Use 章节 原报告严重程度:轻微

    文档未设置独立 'When to Use' 章节说明使用时机

    改进建议:建议在 Quick Reference 后增加 'When to Use' 章节,明确说明本 Skill 适用于 Frappe 报表开发中的语法查询与错误排查场景

亮点

  • 采用清晰的决策树帮助用户选择报表类型
  • 提供完整的代码模板与字段类型对照表
  • Critical Rules 部分有效预防常见开发错误
执行可靠88/100

亮点

  • 明确指定兼容版本范围(Frappe v14-v16)
  • 强调 SQL 参数化查询防止注入风险
  • 对 Prepared Report 的使用条件给出量化建议(>100k 行或 >30 秒)
证据可验 (前四项均值)91/100

取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。

正文静态检测

100 / 100 · skillpi-20261123-no-r3-v1

正文未命中当前规则。

分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。

权限与使用前检查

根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。

  • 管理员或提升权限

    确认确有必要再提升权限;不要关闭防护、绕过证书验证或扩大整个系统的访问权限。

    主文档提及 · 第 25 行

本站展示提示不会授予权限。涉及文件改动、密钥、外部发送或费用时,仍由你使用的工具按需确认。

安全评级与访问范围

safe · 静态证据核验,不代表运行安全保证。

使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。