odoo-qweb-templates – skill Tài liệu & Office cho agent AI
Chuyên gia QWeb template của Odoo cho báo cáo PDF, mẫu email và trang website. Bao gồm t-if, t-foreach, t-field và report action.
Cài skill odoo-qweb-templates bằng một lệnh
Chọn công cụ bạn đang dùng, copy lệnh và dán vào terminal. Skill sẽ nằm trong thư mục skills của công cụ đó và sẵn sàng dùng ở phiên làm việc tiếp theo.
Claude Code
mkdir -p ~/.claude/skills && curl -fsSL https://skill.dn1nguoi.com/z/odoo-qweb-templates-56fc8.tgz | tar xz -C ~/.claude/skills
Gọi trong Claude Code: /odoo-qweb-templates – rồi mô tả công việc bạn muốn làm.
Codex
mkdir -p ~/.codex/skills && curl -fsSL https://skill.dn1nguoi.com/z/odoo-qweb-templates-56fc8.tgz | tar xz -C ~/.codex/skills
Gọi trong Codex: $odoo-qweb-templates – rồi mô tả công việc bạn muốn làm.
Hermes Agent
mkdir -p ~/.hermes/skills && curl -fsSL https://skill.dn1nguoi.com/z/odoo-qweb-templates-56fc8.tgz | tar xz -C ~/.hermes/skills
Gọi trong Hermes Agent: /odoo-qweb-templates – rồi mô tả công việc bạn muốn làm.
DeepSeek
mkdir -p ~/.deepcode/skills && curl -fsSL https://skill.dn1nguoi.com/z/odoo-qweb-templates-56fc8.tgz | tar xz -C ~/.deepcode/skills
Gọi trong DeepSeek: /odoo-qweb-templates – rồi mô tả công việc bạn muốn làm.
Nội dung SKILL.md
Nội dung SKILL.md gốc bằng tiếng Anh.
Odoo 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
1. Activate: Mention @odoo-qweb-templates and describe the report or template needed.
2. Generate: Receive a complete ir.actions.report record and QWeb template.
3. 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](https://www.odoo.com/documentation/17.0/developer/reference/frontend/qweb.html). 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).
Skill liên quan
- office-productivity – Quy trình năng suất văn phòng bao gồm tạo tài liệu, tự động hóa bảng tính, tạo bài…
- onboard – Phân tách tài liệu dự án hỗn hợp (mã nguồn, tài liệu, PDF/Excel/PPT) thành tổng quan có…
- patterns – Tài liệu tham chiếu về các mẫu monopoly.
- pdf-conversion-router – Dùng khi chuyển PDF sang định dạng khác như Markdown, HTML, văn bản, JSON, DOCX hoặc ghi…
- planning-with-files – Làm việc như Manus: dùng file markdown bền vững làm "bộ nhớ làm việc trên đĩa."
- pptx-deck-creation – Tạo bộ slide PPTX chỉnh sửa được, sẵn sàng sản xuất, với kế hoạch nội dung, đặc tả bố…
- presentation-deck – Xây dựng bảng tổng hợp slide có liên kết bằng chứng sau bước thu thập bối cảnh ban đầu…
- price-psychology-strategist – Thiết kế cách trình bày giá, mốc neo và các gói khi ưu đãi cần giá trị và tính công bằng…