About odoo-qweb-templates
A skill for creating and debugging server-side Odoo QWeb templates, primarily for PDF reports. It helps developers produce XML templates with directives, translation support, and report action bindings.
Key features
- 01Generate QWeb XML templates
- 02Create PDF report action bindings
- 03Debug rendering directives
- 04Apply field formatting and output escaping
- 05Support translated report strings
Use cases
- 01Create invoice or delivery-slip reports
- 02Build workflow-triggered email templates
- 03Design website pages with dynamic content
- 04Fix t-if or t-foreach rendering issues
Install
Copy the command and run it in a terminal.
$
npx skills add https:/ / github.com/ sickn33/ agentic-awesome-skills --skill odoo-qweb-templatesAfter installing, type/odoo-qweb-templatesin Claude Code to confirm it loaded.
Details
From the project READMEOdoo QWeb Templates
Overview
QWeb is Odoo's primary templating engine, used for PDF reports, website pages, and email templates. This skill generates correct, well-structured QWeb XML with proper directives, translation support, and report action bindings.
When to Use This Skill
- Creating a custom PDF report (invoice, delivery slip, certificate).
- Building a QWeb email template triggered by workflow actions.
- Designing Odoo website pages with dynamic content.
- Debugging QWeb rendering errors (
t-if,t-foreachissues).
How It Works
- Activate: Mention
@odoo-qweb-templatesand describe the report or template needed. - Generate: Receive a complete
ir.actions.reportrecord and QWeb template. - Debug: Paste a broken template to identify and fix rendering issues.
Examples
Example 1: Custom PDF Report
<!-- Report Action -->
<record id="action_report_patient_card" model="ir.actions.report">
<field name="name">Patient Card</field>
<field name="model">hospital.patient</field>
<field name="report_type">qweb-pdf</field>
<field name="report_name">hospital_management.report_patient_card</field>
<field name="binding_model_id" ref="model_hospital_patient"/>
</record>
<!-- QWeb Template -->
<template id="report_patient_card">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="doc">
<t t-call="web.external_layout">
<div class="page">
<h2>Patient Card</h2>
<table class="table table-bordered">
<tr>
<td><strong>Name:</strong></td>
<td><t t-field="doc.name"/></td>
</tr>
<tr>
<td><strong>Doctor:</strong></td>
<td><t t-field="doc.doctor_id.name"/></td>
</tr>
<tr>
<td><strong>Status:</strong></td>
<td><t t-field="doc.state"/></td>
</tr>
</table>
</div>
</t>
</t>
</t>
</template>
Example 2: Conditional Rendering
<!-- Show a warning block only if the patient is not confirmed -->
<t t-if="doc.state == 'draft'">
<div class="alert alert-warning">
<strong>Warning:</strong> This patient has not been confirmed yet.
</div>
</t>
Best Practices
- ✅ Do: Use
t-fieldfor model fields — Odoo auto-formats dates, monetary values, and booleans correctly. - ✅ Do: Use
t-outfor escaped output of ordinary strings;t-escremains an alias in Odoo 17. Values already marked safe require separate trust review. - ✅ Do: Call
web.external_layoutfor PDF reports to automatically include the company header, footer, and logo. - ✅ Do: Use
_lt()(lazy translation) for translatable string literals inside Python report helpers, not inlinet-esc. - ❌ Don't: Put complex business logic or side effects in QWeb — simple expressions are supported; compute complex values in a model or report
_get_report_values()helper. - ❌ Don't: Forget
t-aswhen usingt-foreach; without it, you can't access the current record in the loop body. - ❌ Don't: Bypass escaping to render untrusted HTML. Sanitize rich content using the target Odoo version's supported mechanisms; marking content safe is a security assertion.
Reference: Odoo 17 QWeb. The sample requires the custom model, fields, access rules and module XML wrapper; test rendering with an authorized user and avoid exposing patient data.
Limitations
- Does not cover website controller routing for dynamic QWeb pages — that requires Python
http.routeknowledge. - Email template QWeb has different variable scope than report QWeb (
objectvsdocs) — this skill primarily focuses on PDF reports. - QWeb JavaScript (used in Kanban/Form widgets) is a different engine; this skill covers server-side QWeb only.
- Does not cover wkhtmltopdf configuration for PDF rendering issues (page size, margins, header/footer overlap).
Comments
Markdown supported