sbknext/forge-frappe-skill

frappe-report-development

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

Ver código-fonte

Como usar

  1. Copie o comando e verifique o pacote antes de instalar no seu ambiente de agente.
  2. Consulte no original as ferramentas, credenciais e ambientes necessários.
  3. Descreva os dados de entrada e a entrega esperada; confira a saída com as fontes.
npx skills add https://github.com/sbknext/forge-frappe-skill --skill frappe-report-development

Antes de começar

  • A instalação não inclui assinatura de modelo, franquia API ou acesso aos seus arquivos.
  • Estrelas e instalações indicam atividade, não um teste independente de qualidade ou segurança.
Documento original do Skill

Renderizado do repositório de origem, preservando títulos, exemplos, código, tabelas, links e imagens.

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

do mesmo repositório

Mais Skills

Todos os Skills
sbknext
Comunidade

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

Instalações / 1h
1
GitHub Stars
18
Atualizado
7 de jun.
sbknext
Comunidade

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

Instalações / 1h
1
GitHub Stars
18
Atualizado
7 de jun.
sbknext
Comunidade

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

Instalações / 1h
1
GitHub Stars
18
Atualizado
7 de jun.
sbknext
Comunidade

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

Instalações / 1h
1
GitHub Stars
18
Atualizado
7 de jun.