sbknext/forge-frappe-skill

frappe-report-development

Build Frappe reports — Query Reports (SQL), Script Reports (Python), filters, columns, charts, formatters, and report permissions.

View source

How to use

  1. Copy the installation command and review the source package before installing it in your own agent environment.
  2. Check the source document for required tools, credentials and supported hosts.
  3. Describe your input and desired deliverable; review the output against the source material.
npx skills add https://github.com/sbknext/forge-frappe-skill --skill frappe-report-development

Before you start

  • Installation does not include a model subscription, API allowance or permission to access your files.
  • Repository stars and installation counts describe activity, not an independent quality or security test.
Original skill document

Rendered from the source repository. Headings, examples, code, tables, links, and referenced images are preserved.

Frappe Report Development

Three report types: Report Builder (no code, UI), Query Report (one SQL), Script Report (Python, full control). Use Query for simple tabular, Script for computed/multi-step.

Query Report

Create a Report (type = Query Report), put SQL in the query box. Filters are referenced as %(key)s:

sql
SELECT
    so.name        AS "Order:Link/Sales Order:160",
    so.customer    AS "Customer:Link/Customer:200",
    so.grand_total AS "Total:Currency:120"
FROM `tabSales Order` so
WHERE so.docstatus = 1
  AND so.company = %(company)s
  AND so.transaction_date BETWEEN %(from_date)s AND %(to_date)s
ORDER BY so.transaction_date

Column header syntax: Label:Fieldtype/Options:Width. Filters injected as named %(...)s params — safe.

Script Report

python
# myapp/myapp/report/order_summary/order_summary.py
import frappe

def execute(filters=None):
    filters = filters or {}
    columns = [
        {"label": "Customer", "fieldname": "customer", "fieldtype": "Link", "options": "Customer", "width": 200},
        {"label": "Total",    "fieldname": "total",    "fieldtype": "Currency", "width": 120},
    ]
    rows = frappe.db.sql("""
        SELECT customer, SUM(grand_total) AS total
        FROM `tabSales Order`
        WHERE docstatus = 1 AND company = %(company)s
        GROUP BY customer
    """, filters, as_dict=True)

    chart = {
        "data": {"labels": [r.customer for r in rows],
                 "datasets": [{"values": [r.total for r in rows]}]},
        "type": "bar",
    }
    return columns, rows, None, chart      # columns, data, message, chart, report_summary

Filters (report .js)

javascript
frappe.query_reports["Order Summary"] = {
    filters: [
        { fieldname: "company",   label: "Company",   fieldtype: "Link", options: "Company", reqd: 1 },
        { fieldname: "from_date", label: "From",       fieldtype: "Date", default: frappe.datetime.month_start() },
        { fieldname: "to_date",   label: "To",         fieldtype: "Date", default: frappe.datetime.get_today() },
    ],
    formatter(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">${value}</span>`;
        return value;
    },
};

Rules

  • Query Reports: only %(name)s params — never string-concat filter values (injection).
  • Set report roles so only intended users can run/export it.
  • Heavy aggregations → add indexes, or precompute into a summary DocType refreshed by a scheduler job.
  • Return a chart dict for a built-in visualization; report_summary for top KPI cards.
  • For huge exports, prefer a background job writing a file over a synchronous report run.
  • Report print formats: drop {report_name}.html beside the report .py/.js — client-side microtemplating (not Jinja); data available as data, filters, report.

Source: https://docs.frappe.io/framework/user/en/desk/printing , https://docs.frappe.io/framework/user/en/guides/reports-and-printing/print-format-for-reports

from this repository

More skills

All skills
sbknext
Community

frappe-app-development

Scaffold, architect, and build production-grade custom Frappe/ERPNext apps. Covers app structure, DocType design, hooks.py configuration, background jobs, service layers, REST APIs, permissions, and testing. Use when creating a new Frappe app, adding a module, setting up scheduler events, implementing docevents, writing whitelisted APIs, or debugging Frappe-specific issues. Trigger on: "create Frappe app", "new DocType", "add a hook", "background job", "frappe.enqueue", "whitelist API", "custom

1h installs
1
GitHub stars
18
Updated
Jun 7
sbknext
Community

frappe-client-scripting

Customize Frappe desk forms and lists with client scripts — frappe.ui.form.on handlers, field events, setquery link filters, setdfproperty, custom buttons, frappe.call, and list view settings. Use when adding form interactivity, dynamic filters, validation, or buttons in the desk UI. Trigger on: "client script", "frappe.ui.form.on", "form event", "setquery", "custom button", "frappe.call", "list view settings", "curfrm".

1h installs
1
GitHub stars
18
Updated
Jun 7
sbknext
Community

frappe-database-orm

Query and mutate data in Frappe safely — getdoc/getall/getlist, frappe.db.getvalue/setvalue, parameterized frappe.db.sql, Query Builder (frappe.qb), transactions, bulk ops, and performance. Use when reading or writing data, optimizing slow queries, or avoiding SQL injection. Trigger on: "frappe.db.sql", "frappe.getall", "query builder", "frappe.qb", "bulk update", "N+1", "db transaction", "getvalue setvalue".

1h installs
1
GitHub stars
18
Updated
Jun 7
sbknext
Community

frappe-testing

Write and run tests for Frappe/ERPNext apps — FrappeTestCase, test records, fixtures, mocking, permission tests, running with bench run-tests, and CI. Use when adding test coverage, doing TDD on a DocType or API, or setting up a test pipeline. Trigger on: "Frappe test", "FrappeTestCase", "bench run-tests", "unit test DocType", "test fixtures", "TDD frappe".

1h installs
1
GitHub stars
18
Updated
Jun 7