SlideShare a Scribd company logo
Qweb Templates and Operations in Odoo
18
Enterprise
Enterprise
In this slide, we’ll dive into Qweb templates in Odoo 18, covering
their structure, operations, and customization options. We’ll also look
at how to extend Qweb templates and perform key operations to
optimize your reports and web content.
Introduction
Enterprise
Qweb Templates
Qweb templates in Odoo 18 are XML-based tools for generating
dynamic content like web pages, PDF reports, and emails. They
pull data from Odoo models, making them ideal for documents
like invoices and purchase orders. Optimizations in Odoo 18 have
improved performance, enabling faster rendering and reduced
memory usage, even with large datasets or complex reports.
Enterprise
Key Features of Qweb in Odoo 18
● Dynamic Content Rendering: Qweb templates can pull and
display real-time data directly from Odoo models, allowing for
dynamic, data-driven reports and web pages.
● Customizable Layouts: The flexibility of Qweb allows developers
to create detailed, custom layouts to meet specific business
needs.
Enterprise
Key Features of Qweb in Odoo 18
● Modular Structure: Qweb templates can be extended or
overridden, enabling customization without altering the original
code, which is helpful for updates or specific adjustments.
● Integration with Reports: Odoo’s reporting system, especially
for generating PDF and HTML documents, heavily relies on Qweb
templates.
Enterprise
Key Features of Qweb in Odoo 18
● Reusability: Qweb supports reusable snippets that can be integrated
into multiple templates, reducing code repetition and simplifying
maintenance.
Enterprise
Structure of a Qweb Template
Qweb templates are defined in XML and consist of tags that specify
how content should be structured and displayed. Here's an
example of a simple Qweb template for generating an invoice
report:
Enterprise
<template id="report_invoice">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="o">
<t t-call="account.report_invoice_document">
<t t-set="company" t-value="o.company_id"/>
<t t-set="date" t-value="o.date_invoice"/>
<!-- Add more content here -->
</t>
</t>
</t>
</template>
Enterprise
● <template>: The root element that defines the Qweb template,
identified by a unique id.
● <t>: A versatile tag used for dynamic operations like calling other
templates, looping through data, or defining variables.
● t-call: Calls another template, enabling modular and reusable code.
● t-foreach: Iterates over a list of records, rendering content
dynamically for each item.
● t-set: Defines variables that can be used within the template to display
dynamic content.
Enterprise
Key Operations in Qweb Templates
1. Defining Variables (t-set and t-value)
You can use t-set to define variables and t-value to assign values
that will be used later in the template.
<t t-set="company_name" t-value="o.company_id.name"/>
<p>Company Name: <t t-esc="company_name"/></p>
Enterprise
2. Looping through Data (t-foreach)
Use t-foreach to loop through records and display data dynamically.
<t t-foreach="o.invoice_line_ids" t-as="line">
<tr>
<td><t t-esc="line.product_id.name"/></td>
<td><t t-esc="line.quantity"/></td>
<td><t t-esc="line.price_unit"/></td>
</tr>
</t>
Enterprise
3. Conditional Statements (t-if, t-elif, and t-else)
Conditional rendering allows you to control the display of content
based on specific conditions.
<t t-if="o.state == 'draft'">
<p>Invoice is in draft state.</p>
<t t-elif="o.state == 'open'">
<p>Invoice is open.</p>
<t t-else="">
<p>Invoice is in another state.</p>
</t>
Enterprise
4. Including Other Templates (t-call)
You can call another template inside the current one to include pre-defined
content.
<t t-call="account.report_invoice_footer"/>
Enterprise
5. Escaping or Rendering Raw Content (t-esc and t-raw)
Use t-esc to escape content (e.g., special characters) or t-raw to
render raw HTML.
<p>Escaped Content: <t t-esc="o.name"/></p>
<p>Raw Content: <t t-raw="o.description_html"/></p>
Enterprise
6. Setting Dynamic Attributes (t-att)
Dynamically set HTML element attributes using t-att.
<img t-att-src="'/web/image/product.product/' + str(o.product_id.id) +
'/image_1920'"/>
Enterprise
7. Formatting Dates and Numbers
Format dates and numbers using Odoo’s formatLang and
formatDate methods.
<p>Date:
<t t-esc="formatDate(o.date_invoice, 'dd MMMM yyyy')"/>
</p>
Enterprise
8. Debugging Templates (t-debug and t-log)
Use t-debug and t-log for debugging Qweb templates, displaying or logging
variable data.
<t t-debug="o.partner_id.name"/>
<t t-log="o.partner_id.name"/>
Enterprise
Extending and Customizing Qweb Templates
You can easily extend or override Qweb templates in Odoo 18 by inheriting
the original template and modifying its content. This allows developers to
customize templates without altering the core template files.
Enterprise
Inheriting a Template
<template id="report_invoice_inherit"
inherit_id="account.report_invoice_document">
<xpath expr="//div[@class='header']" position="after">
<p>Additional content added to the invoice report.</p>
</xpath>
</template>
Enterprise
Overriding a Template
<template id="report_invoice">
<!-- Custom content here -->
</template>
Enterprise
Conclusion
Qweb templates in Odoo 18 are essential for creating dynamic, data-
driven documents and reports. Their XML-based structure and
improved performance make them a key tool for developers to
customize content efficiently, meeting specific business needs.
For More Info.
Check our company website for related blogs
and Odoo book.
Check our YouTube channel for
functional and technical videos in Odoo.
Enterprise
www.cybrosys.com

More Related Content

PPTX
Reporting - Printed (Pdf) Reports
PPTX
How to Create a PDF Report in Odoo 18 - Odoo Slides
DOCX
QWeb Report in odoo
PPTX
Report Actions In Odoo 17 - Odoo 17 Slides
PPTX
How to Modify Existing Web Pages in Odoo 18
PDF
oddo ERP Introductionklsjflsjlsjlfjslfjsdl
PPTX
URLs and Routing in the Odoo 17 Website App
PPT
Odoo website themes
Reporting - Printed (Pdf) Reports
How to Create a PDF Report in Odoo 18 - Odoo Slides
QWeb Report in odoo
Report Actions In Odoo 17 - Odoo 17 Slides
How to Modify Existing Web Pages in Odoo 18
oddo ERP Introductionklsjflsjlsjlfjslfjsdl
URLs and Routing in the Odoo 17 Website App
Odoo website themes

Similar to Qweb Templates and Operations in Odoo 18 (20)

PPTX
How to Manage Catalog View in Invoice & Bill in Odoo 18
PPTX
Revamp in Odoo 18 Document - Odoo 18 Slides
DOC
Odoo 12 index
PPTX
Client Actions In Odoo 17 - Odoo 17 Slides
PDF
Jornadas Odoo 2015 - Charla con Odoo S. A.
PPTX
How to Customize Header_Footer for All Reports in odoo
PPTX
Why Browser Debugger is a Developer's Best Friend
PDF
Saving Time, Making Money: A Case Study on Enterprise Resource Planning Softw...
PPTX
URLS and routing in odoo 18 - Odoo Slides
PPTX
How to Create an App Using Odoo 17 Studio
PPTX
Properties of Odoo 17 Knowledge Module - Odoo 17 POS
PPTX
How to Create a Theme Module in Odoo 17 - Odoo 17 Slides
PPTX
How to Sell Your Products in Odoo 17 Website
PPTX
Odoo Open ERp
PPTX
Odoo (Build module, Security, ORM)
PDF
Odoo system presentation.pdf
PPTX
Odoo Training
PDF
EECI 2010 - The Power of ExpressionEngine's Dynamic Templates
PPTX
Odoo ERP Basic Module.pptx
PPTX
What are the Improvements in Odoo 18 PDF Quote Builder
How to Manage Catalog View in Invoice & Bill in Odoo 18
Revamp in Odoo 18 Document - Odoo 18 Slides
Odoo 12 index
Client Actions In Odoo 17 - Odoo 17 Slides
Jornadas Odoo 2015 - Charla con Odoo S. A.
How to Customize Header_Footer for All Reports in odoo
Why Browser Debugger is a Developer's Best Friend
Saving Time, Making Money: A Case Study on Enterprise Resource Planning Softw...
URLS and routing in odoo 18 - Odoo Slides
How to Create an App Using Odoo 17 Studio
Properties of Odoo 17 Knowledge Module - Odoo 17 POS
How to Create a Theme Module in Odoo 17 - Odoo 17 Slides
How to Sell Your Products in Odoo 17 Website
Odoo Open ERp
Odoo (Build module, Security, ORM)
Odoo system presentation.pdf
Odoo Training
EECI 2010 - The Power of ExpressionEngine's Dynamic Templates
Odoo ERP Basic Module.pptx
What are the Improvements in Odoo 18 PDF Quote Builder
Ad

More from Celine George (20)

PPTX
How to Implement OWL Notification Service in Odoo 18
PPTX
Tracking Profit Margins in Sales Orders with Odoo 18
PPTX
How to Configure Outgoing Shipment in 3 Steps Using Odoo 18
PPTX
How to Configure Outgoing Shipment in 1 Step Using Odoo 18.pptx
PPTX
How to Configure Outgoing Shipment in 2 Steps Using Odoo 18
PPTX
How to Add New Applicants in Odoo 18 Recruitment
PPTX
How to Analyze the Recruitment Process in Odoo 18 Recruitment
PPTX
How to Manage Referral Reporting in Odoo 18 Referrals
PPTX
How to Set, Track, & Review Employee Goals in Odoo 18 Appraisals
PPTX
Revamp in MTO Odoo 18 Inventory - Odoo Slides
PPTX
How to Manage Starshipit in Odoo 18 - Odoo Slides
PPTX
How to Manage Bill Control Policy in Odoo 18
PPTX
How to Manage Loyalty Points in Odoo 18 Sales
PPTX
Odoo 18 Sales_ Managing Quotation Validity
PPTX
How to Manage Global Discount in Odoo 18 POS
PPTX
How to Manage Leads in Odoo 18 CRM - Odoo Slides
PPTX
Tips Management in Odoo 18 POS - Odoo Slides
PPTX
How to Close Subscription in Odoo 18 - Odoo Slides
PPTX
Kanban Cards _ Mass Action in Odoo 18.2 - Odoo Slides
PPTX
How to Track Skills & Contracts Using Odoo 18 Employee
How to Implement OWL Notification Service in Odoo 18
Tracking Profit Margins in Sales Orders with Odoo 18
How to Configure Outgoing Shipment in 3 Steps Using Odoo 18
How to Configure Outgoing Shipment in 1 Step Using Odoo 18.pptx
How to Configure Outgoing Shipment in 2 Steps Using Odoo 18
How to Add New Applicants in Odoo 18 Recruitment
How to Analyze the Recruitment Process in Odoo 18 Recruitment
How to Manage Referral Reporting in Odoo 18 Referrals
How to Set, Track, & Review Employee Goals in Odoo 18 Appraisals
Revamp in MTO Odoo 18 Inventory - Odoo Slides
How to Manage Starshipit in Odoo 18 - Odoo Slides
How to Manage Bill Control Policy in Odoo 18
How to Manage Loyalty Points in Odoo 18 Sales
Odoo 18 Sales_ Managing Quotation Validity
How to Manage Global Discount in Odoo 18 POS
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Tips Management in Odoo 18 POS - Odoo Slides
How to Close Subscription in Odoo 18 - Odoo Slides
Kanban Cards _ Mass Action in Odoo 18.2 - Odoo Slides
How to Track Skills & Contracts Using Odoo 18 Employee
Ad

Recently uploaded (20)

PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
Sports Quiz easy sports quiz sports quiz
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
Classroom Observation Tools for Teachers
PPTX
master seminar digital applications in india
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
01-Introduction-to-Information-Management.pdf
PPTX
Institutional Correction lecture only . . .
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
VCE English Exam - Section C Student Revision Booklet
Microbial diseases, their pathogenesis and prophylaxis
Sports Quiz easy sports quiz sports quiz
human mycosis Human fungal infections are called human mycosis..pptx
Final Presentation General Medicine 03-08-2024.pptx
2.FourierTransform-ShortQuestionswithAnswers.pdf
Module 4: Burden of Disease Tutorial Slides S2 2025
Classroom Observation Tools for Teachers
master seminar digital applications in india
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Microbial disease of the cardiovascular and lymphatic systems
01-Introduction-to-Information-Management.pdf
Institutional Correction lecture only . . .
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
102 student loan defaulters named and shamed – Is someone you know on the list?
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Supply Chain Operations Speaking Notes -ICLT Program
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx

Qweb Templates and Operations in Odoo 18

  • 1. Qweb Templates and Operations in Odoo 18 Enterprise
  • 2. Enterprise In this slide, we’ll dive into Qweb templates in Odoo 18, covering their structure, operations, and customization options. We’ll also look at how to extend Qweb templates and perform key operations to optimize your reports and web content. Introduction
  • 3. Enterprise Qweb Templates Qweb templates in Odoo 18 are XML-based tools for generating dynamic content like web pages, PDF reports, and emails. They pull data from Odoo models, making them ideal for documents like invoices and purchase orders. Optimizations in Odoo 18 have improved performance, enabling faster rendering and reduced memory usage, even with large datasets or complex reports.
  • 4. Enterprise Key Features of Qweb in Odoo 18 ● Dynamic Content Rendering: Qweb templates can pull and display real-time data directly from Odoo models, allowing for dynamic, data-driven reports and web pages. ● Customizable Layouts: The flexibility of Qweb allows developers to create detailed, custom layouts to meet specific business needs.
  • 5. Enterprise Key Features of Qweb in Odoo 18 ● Modular Structure: Qweb templates can be extended or overridden, enabling customization without altering the original code, which is helpful for updates or specific adjustments. ● Integration with Reports: Odoo’s reporting system, especially for generating PDF and HTML documents, heavily relies on Qweb templates.
  • 6. Enterprise Key Features of Qweb in Odoo 18 ● Reusability: Qweb supports reusable snippets that can be integrated into multiple templates, reducing code repetition and simplifying maintenance.
  • 7. Enterprise Structure of a Qweb Template Qweb templates are defined in XML and consist of tags that specify how content should be structured and displayed. Here's an example of a simple Qweb template for generating an invoice report:
  • 8. Enterprise <template id="report_invoice"> <t t-call="web.html_container"> <t t-foreach="docs" t-as="o"> <t t-call="account.report_invoice_document"> <t t-set="company" t-value="o.company_id"/> <t t-set="date" t-value="o.date_invoice"/> <!-- Add more content here --> </t> </t> </t> </template>
  • 9. Enterprise ● <template>: The root element that defines the Qweb template, identified by a unique id. ● <t>: A versatile tag used for dynamic operations like calling other templates, looping through data, or defining variables. ● t-call: Calls another template, enabling modular and reusable code. ● t-foreach: Iterates over a list of records, rendering content dynamically for each item. ● t-set: Defines variables that can be used within the template to display dynamic content.
  • 10. Enterprise Key Operations in Qweb Templates 1. Defining Variables (t-set and t-value) You can use t-set to define variables and t-value to assign values that will be used later in the template. <t t-set="company_name" t-value="o.company_id.name"/> <p>Company Name: <t t-esc="company_name"/></p>
  • 11. Enterprise 2. Looping through Data (t-foreach) Use t-foreach to loop through records and display data dynamically. <t t-foreach="o.invoice_line_ids" t-as="line"> <tr> <td><t t-esc="line.product_id.name"/></td> <td><t t-esc="line.quantity"/></td> <td><t t-esc="line.price_unit"/></td> </tr> </t>
  • 12. Enterprise 3. Conditional Statements (t-if, t-elif, and t-else) Conditional rendering allows you to control the display of content based on specific conditions. <t t-if="o.state == 'draft'"> <p>Invoice is in draft state.</p> <t t-elif="o.state == 'open'"> <p>Invoice is open.</p> <t t-else=""> <p>Invoice is in another state.</p> </t>
  • 13. Enterprise 4. Including Other Templates (t-call) You can call another template inside the current one to include pre-defined content. <t t-call="account.report_invoice_footer"/>
  • 14. Enterprise 5. Escaping or Rendering Raw Content (t-esc and t-raw) Use t-esc to escape content (e.g., special characters) or t-raw to render raw HTML. <p>Escaped Content: <t t-esc="o.name"/></p> <p>Raw Content: <t t-raw="o.description_html"/></p>
  • 15. Enterprise 6. Setting Dynamic Attributes (t-att) Dynamically set HTML element attributes using t-att. <img t-att-src="'/web/image/product.product/' + str(o.product_id.id) + '/image_1920'"/>
  • 16. Enterprise 7. Formatting Dates and Numbers Format dates and numbers using Odoo’s formatLang and formatDate methods. <p>Date: <t t-esc="formatDate(o.date_invoice, 'dd MMMM yyyy')"/> </p>
  • 17. Enterprise 8. Debugging Templates (t-debug and t-log) Use t-debug and t-log for debugging Qweb templates, displaying or logging variable data. <t t-debug="o.partner_id.name"/> <t t-log="o.partner_id.name"/>
  • 18. Enterprise Extending and Customizing Qweb Templates You can easily extend or override Qweb templates in Odoo 18 by inheriting the original template and modifying its content. This allows developers to customize templates without altering the core template files.
  • 19. Enterprise Inheriting a Template <template id="report_invoice_inherit" inherit_id="account.report_invoice_document"> <xpath expr="//div[@class='header']" position="after"> <p>Additional content added to the invoice report.</p> </xpath> </template>
  • 20. Enterprise Overriding a Template <template id="report_invoice"> <!-- Custom content here --> </template>
  • 21. Enterprise Conclusion Qweb templates in Odoo 18 are essential for creating dynamic, data- driven documents and reports. Their XML-based structure and improved performance make them a key tool for developers to customize content efficiently, meeting specific business needs.
  • 22. For More Info. Check our company website for related blogs and Odoo book. Check our YouTube channel for functional and technical videos in Odoo. Enterprise www.cybrosys.com