[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-bec51e52-f66b-4d03-9a15-84cbc1d558d2":3,"$fH2CFvUktO96GrVd0HeTRvhevg2rxl9ivJCNyxFys9Pw":43},{"id":4,"title":5,"description":6,"categoryId":7,"moduleId":8,"tags":9,"prompt":10,"icon":11,"source":12,"sourceUrl":13,"authorId":14,"authorName":15,"isPublic":16,"stars":17,"runs":18,"createdAt":19,"updatedAt":19,"module":20,"category":27,"packages":34},"bec51e52-f66b-4d03-9a15-84cbc1d558d2","odoo-qweb-templates","Odoo QWeb模板专家，涵盖PDF报告、电子邮件模板和网站页面的t-if、t-foreach、t-field和报告操作。","cat_prod_document","mod_productivity","sickn33,productivity","---\nname: odoo-qweb-templates\ndescription: \"Expert in Odoo QWeb templating for PDF reports, email templates, and website pages. Covers t-if, t-foreach, t-field, and report actions.\"\nrisk: safe\nsource: \"self\"\n---\n\n# Odoo QWeb Templates\n\n## Overview\n\nQWeb 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.\n\n## When to Use This Skill\n\n- Creating a custom PDF report (invoice, delivery slip, certificate).\n- Building a QWeb email template triggered by workflow actions.\n- Designing Odoo website pages with dynamic content.\n- Debugging QWeb rendering errors (`t-if`, `t-foreach` issues).\n\n## How It Works\n\n1. **Activate**: Mention `@odoo-qweb-templates` and describe the report or template needed.\n2. **Generate**: Receive a complete `ir.actions.report` record and QWeb template.\n3. **Debug**: Paste a broken template to identify and fix rendering issues.\n\n## Examples\n\n### Example 1: Custom PDF Report\n\n```xml\n\u003C!-- Report Action -->\n\u003Crecord id=\"action_report_patient_card\" model=\"ir.actions.report\">\n    \u003Cfield name=\"name\">Patient Card\u003C\u002Ffield>\n    \u003Cfield name=\"model\">hospital.patient\u003C\u002Ffield>\n    \u003Cfield name=\"report_type\">qweb-pdf\u003C\u002Ffield>\n    \u003Cfield name=\"report_name\">hospital_management.report_patient_card\u003C\u002Ffield>\n    \u003Cfield name=\"binding_model_id\" ref=\"model_hospital_patient\"\u002F>\n\u003C\u002Frecord>\n\n\u003C!-- QWeb Template -->\n\u003Ctemplate id=\"report_patient_card\">\n    \u003Ct t-call=\"web.html_container\">\n        \u003Ct t-foreach=\"docs\" t-as=\"doc\">\n            \u003Ct t-call=\"web.external_layout\">\n                \u003Cdiv class=\"page\">\n                    \u003Ch2>Patient Card\u003C\u002Fh2>\n                    \u003Ctable class=\"table table-bordered\">\n                        \u003Ctr>\n                            \u003Ctd>\u003Cstrong>Name:\u003C\u002Fstrong>\u003C\u002Ftd>\n                            \u003Ctd>\u003Ct t-field=\"doc.name\"\u002F>\u003C\u002Ftd>\n                        \u003C\u002Ftr>\n                        \u003Ctr>\n                            \u003Ctd>\u003Cstrong>Doctor:\u003C\u002Fstrong>\u003C\u002Ftd>\n                            \u003Ctd>\u003Ct t-field=\"doc.doctor_id.name\"\u002F>\u003C\u002Ftd>\n                        \u003C\u002Ftr>\n                        \u003Ctr>\n                            \u003Ctd>\u003Cstrong>Status:\u003C\u002Fstrong>\u003C\u002Ftd>\n                            \u003Ctd>\u003Ct t-field=\"doc.state\"\u002F>\u003C\u002Ftd>\n                        \u003C\u002Ftr>\n                    \u003C\u002Ftable>\n                \u003C\u002Fdiv>\n            \u003C\u002Ft>\n        \u003C\u002Ft>\n    \u003C\u002Ft>\n\u003C\u002Ftemplate>\n```\n\n### Example 2: Conditional Rendering\n\n```xml\n\u003C!-- Show a warning block only if the patient is not confirmed -->\n\u003Ct t-if=\"doc.state == 'draft'\">\n    \u003Cdiv class=\"alert alert-warning\">\n        \u003Cstrong>Warning:\u003C\u002Fstrong> This patient has not been confirmed yet.\n    \u003C\u002Fdiv>\n\u003C\u002Ft>\n```\n\n## Best Practices\n\n- ✅ **Do:** Use `t-field` for model fields — Odoo auto-formats dates, monetary values, and booleans correctly.\n- ✅ **Do:** Use `t-out` (Odoo 15+) for safe HTML output of non-field strings. Use `t-esc` only on Odoo 14 and below (it HTML-escapes output).\n- ✅ **Do:** Call `web.external_layout` for PDF reports to automatically include the company header, footer, and logo.\n- ✅ **Do:** Use `_lt()` (lazy translation) for translatable string literals inside Python report helpers, not inline `t-esc`.\n- ❌ **Don't:** Use raw Python expressions inside QWeb — compute values in the model or a report `_get_report_values()` helper.\n- ❌ **Don't:** Forget `t-as` when using `t-foreach`; without it, you can't access the current record in the loop body.\n- ❌ **Don't:** Use `t-esc` where you intend to render HTML content — it will escape the tags and print them as raw text.\n\n## Limitations\n\n- Does not cover **website controller routing** for dynamic QWeb pages — that requires Python `http.route` knowledge.\n- **Email template** QWeb has different variable scope than report QWeb (`object` vs `docs`) — this skill primarily focuses on PDF reports.\n- QWeb JavaScript (used in Kanban\u002FForm widgets) is a different engine; this skill covers **server-side QWeb only**.\n- Does not cover **wkhtmltopdf configuration** for PDF rendering issues (page size, margins, header\u002Ffooter overlap).\n","","imported","https:\u002F\u002Fgithub.com\u002Fsickn33\u002Fantigravity-awesome-skills","user_system_seed","SkillOPIC",true,64,1834,"2026-05-16 13:32:23",{"id":8,"name":21,"slug":22,"icon":23,"description":24,"sort":25,"createdAt":26},"效率工具","productivity","mdi-lightning-bolt-outline","文档处理、数据分析、自动化工作流",4,"2026-05-16 12:53:40",{"id":7,"name":28,"slug":29,"icon":30,"description":31,"moduleId":8,"sort":32,"skillCount":33,"createdAt":26},"文档处理","document","mdi-file-document-outline","PDF\u002FWord\u002FExcel\u002FPPT 处理",1,23,[35],{"id":36,"skillId":4,"version":37,"fileName":38,"fileSize":39,"filePath":40,"fileHash":41,"manifest":42,"createdAt":19},"8e70aa7c-4ff7-488e-a1a4-e9759889132b","1.0.0","odoo-qweb-templates.zip",1794,"uploads\u002Fskills\u002Fbec51e52-f66b-4d03-9a15-84cbc1d558d2\u002Fodoo-qweb-templates.zip","6e95ce9af0bfe48b2195153c3f48b2f4ef0538a87502cd5b0663c5155ba71a76","[{\"path\":\"SKILL.md\",\"isDirectory\":false,\"size\":4134}]",{"code":44,"message":45,"data":46},200,"success",{"items":47,"stats":48,"page":51},[],{"averageRating":49,"totalRatings":49,"ratingCounts":50},0,[49,49,49,49,49],{"limit":52,"offset":49,"hasMore":53,"nextOffset":52,"ratedOnly":16},15,false]