Reports logo

Reports

Organization
lubusIN
reports

Create reports in Frappe including Report Builder, Query Reports (SQL), and Script Reports (Python + JS). Use when building data analysis views, dashboards, or custom reporting features.

Overview

PublisherlubusIN
Repositoryfrappe-skills
Skill namereports
Stars
62
Forks
23
Bundled files
1
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 1 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by lubusIN on GitHub. Read the source before you install it.

Installation

Install the Reports AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/lubusIN/frappe-skills.git /tmp/frappe-skills
mkdir -p .claude/skills
cp -r /tmp/frappe-skills/reports .claude/skills/reports
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Reports in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Reports on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Reports is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Frappe Reports

Build reports using Report Builder, Query Reports (SQL), or Script Reports (Python + JS).

When to use

  • Creating data analysis or summary reports
  • Building SQL-based query reports
  • Implementing complex reports with Python logic and JS UI
  • Adding custom filters, formatters, and charts to reports
  • Creating printable report formats

Inputs required

  • Report purpose and data requirements
  • Source DocType(s) for the report
  • Filter requirements
  • Column definitions (fields, types, formatting)
  • Whether report is standard (app-bundled) or custom (site-specific)

Procedure

0) Choose report type

TypeComplexityCode RequiredBest For
Report BuilderLowNoneSimple field selection, grouping, sorting
Query ReportMediumSQL onlyDirect SQL queries, joins, aggregations
Script ReportHighPython + JSComplex logic, computed fields, dynamic filters

1) Report Builder

Create via UI with no code:

  1. Navigate to the Report list → New Report
  2. Select Reference DocType
  3. Choose Report Type = "Report Builder"
  4. Add columns, filters, sorting, and grouping via the builder UI

2) Query Report

Reports using raw SQL queries:

  1. Create Report → Type = "Query Report"
  2. Set Reference DocType (controls permissions)
  3. Write SQL query
sql
SELECT
    `tabSales Order`.name AS "Sales Order:Link/Sales Order:200",
    `tabSales Order`.customer AS "Customer:Link/Customer:200",
    `tabSales Order`.transaction_date AS "Date:Date:120",
    `tabSales Order`.grand_total AS "Grand Total:Currency:150",
    `tabSales Order`.status AS "Status:Data:100"
FROM `tabSales Order`
WHERE `tabSales Order`.docstatus = 1
    {% if filters.company %}
    AND `tabSales Order`.company = %(company)s
    {% endif %}
    {% if filters.from_date %}
    AND `tabSales Order`.transaction_date >= %(from_date)s
    {% endif %}
ORDER BY `tabSales Order`.transaction_date DESC

Column format in SELECT: "Label:Fieldtype/Options:Width"

FieldtypeExample
Link"Customer:Link/Customer:200"
Currency"Amount:Currency:150"
Date"Date:Date:120"
Int"Quantity:Int:100"
Data"Status:Data:100"

Filter variables: Use %(filter_name)s for parameterized queries.

3) Script Report (standard)

For app-bundled reports with full Python + JS control:

Create the report structure:

my_app/
└── my_module/
    └── report/
        └── sales_summary/
            ├── sales_summary.json    # Report metadata
            ├── sales_summary.py      # Python data logic
            └── sales_summary.js      # JS filters and UI

Python script (sales_summary.py):

python
import frappe
from frappe import _

def execute(filters=None):
    columns = get_columns()
    data = get_data(filters)
    chart = get_chart(data)
    return columns, data, None, chart

def get_columns():
    return [
        {
            "label": _("Customer"),
            "fieldname": "customer",
            "fieldtype": "Link",
            "options": "Customer",
            "width": 200
        },
        {
            "label": _("Total Orders"),
            "fieldname": "total_orders",
            "fieldtype": "Int",
            "width": 120
        },
        {
            "label": _("Total Amount"),
            "fieldname": "total_amount",
            "fieldtype": "Currency",
            "width": 150
        },
        {
            "label": _("Average Order"),
            "fieldname": "avg_order",
            "fieldtype": "Currency",
            "width": 150
        }
    ]

def get_data(filters):
    conditions = get_conditions(filters)

    data = frappe.db.sql("""
        SELECT
            customer,
            COUNT(name) as total_orders,
            SUM(grand_total) as total_amount,
            AVG(grand_total) as avg_order
        FROM `tabSales Order`
        WHERE docstatus = 1 {conditions}
        GROUP BY customer
        ORDER BY total_amount DESC
    """.format(conditions=conditions), filters, as_dict=True)

    return data

def get_conditions(filters):
    conditions = ""
    if filters.get("company"):
        conditions += " AND company = %(company)s"
    if filters.get("from_date"):
        conditions += " AND transaction_date >= %(from_date)s"
    if filters.get("to_date"):
        conditions += " AND transaction_date <= %(to_date)s"
    return conditions

def get_chart(data):
    if not data:
        return None

    return {
        "data": {
            "labels": [d.customer for d in data[:10]],
            "datasets": [{
                "name": _("Total Amount"),
                "values": [d.total_amount for d in data[:10]]
            }]
        },
        "type": "bar"
    }

JavaScript script (sales_summary.js):

javascript
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)
        },
        {
            fieldname: "to_date",
            label: __("To Date"),
            fieldtype: "Date",
            default: frappe.datetime.get_today()
        }
    ],

    onload(report) {
        // Custom initialization
    },

    formatter(value, row, column, data, default_formatter) {
        value = default_formatter(value, row, column, data);

        // Highlight high-value customers
        if (column.fieldname === "total_amount" && data.total_amount > 100000) {
            value = `<span style="color: green; font-weight: bold">${value}</span>`;
        }

        return value;
    }
};

Report JSON (sales_summary.json):

json
{
    "name": "Sales Summary",
    "doctype": "Report",
    "report_type": "Script Report",
    "ref_doctype": "Sales Order",
    "module": "My Module",
    "is_standard": "Yes",
    "disabled": 0
}

4) Add report print format

Create sales_summary.html in the report folder for a custom print layout:

html
<h2>Sales Summary Report</h2>
<table class="table table-bordered">
    <tr>
        <th>Customer</th>
        <th>Orders</th>
        <th>Total</th>
    </tr>
    {% for row in data %}
    <tr>
        <td>{{ row.customer }}</td>
        <td>{{ row.total_orders }}</td>
        <td>{{ frappe.format(row.total_amount, {fieldtype: 'Currency'}) }}</td>
    </tr>
    {% endfor %}
</table>

5) Register report in hooks (optional)

Reports are auto-discovered if they follow the standard directory structure. No hooks.py entry is needed for standard reports.

Verification

  • Report appears in Report list
  • Filters work correctly and affect results
  • Columns display with proper formatting
  • Chart renders (if applicable)
  • Permissions respected (only authorized users see data)
  • Print format works
  • Performance acceptable for expected data volume

Failure modes / debugging

  • Report not found: Check module path and is_standard setting; run bench migrate
  • SQL syntax error: Test query in bench --site <site> mariadb first
  • No data returned: Check docstatus filter; verify filters match data
  • Permission denied: Verify Reference DocType permissions for the user's role
  • Slow query: Add indexes; use Query Builder; limit result set

Escalation

  • For DocType schema → doctype-development
  • For API endpoints (report data via API) → api-development
  • For Desk UI customization → desk-customization

References

Guardrails

  • Validate filters: Check filter values before building queries; handle empty/invalid input
  • Handle empty results: Always handle case where query returns no data; show appropriate message
  • Use frappe.db.escape(): Escape user input in SQL queries to prevent injection
  • Limit result sets: Add LIMIT clause or pagination for large datasets
  • Check permissions in execute: Verify user has permission to see the data

Common Mistakes

MistakeWhy It FailsFix
SQL injection via filtersSecurity vulnerabilityUse frappe.db.escape() or Query Builder with parameters
Missing permission checksUnauthorized data accessVerify frappe.has_permission() or filter by allowed records
Unbounded queriesTimeouts, memory issuesAdd LIMIT, use pagination, or filter by date range
Wrong column fieldtypeFormatting issuesMatch column fieldtype to data (Currency, Date, etc.)
Not handling None in aggregationsErrors or wrong totalsUse COALESCE() or IFNULL() in SQL
Hardcoded docstatus assumptionsMissing draft/cancelled recordsExplicitly filter docstatus based on report needs

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Reports AI skill do?

Create reports in Frappe including Report Builder, Query Reports (SQL), and Script Reports (Python + JS). Use when building data analysis views, dashboards, or custom reporting features.

Why use Reports on TypingMind?

Because you install it once and use it with any model. Reports is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Reports in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/lubusIN/frappe-skills/tree/main/reports. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Reports?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Reports?

As many as you like. As long as a model supports skills, you can use Reports with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Reports AI skill free?

Yes. It is published on GitHub by lubusIN under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇