Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Odoo 10 - Qweb t-if t-else syntax

I do not know which is the right syntax for if-else in qweb.

<t t-if="origin != l.origin">
  <td>foo</td>
<t t-else/>
  <td>bar</td>
</t>

What is wrong here?

like image 889
M.E. Avatar asked Jan 02 '18 23:01

M.E.


People also ask

How to create a qweb report in Odoo?

In every Industry, a report is an essential factor to analyze their business process efficiency. Odoo also supports Qweb reports for easy report making. This is the technical document which helps to create a report. In an XML file we can declare a report inside the ‘ <report></report>’ tag.

How to make a simple PDF report in Odoo using XML?

For making a simple pdf report in Odoo we can go through the following steps In an XML file we can declare a report inside the ‘ <report></report>’ tag. . - model:- It is a mandatory field which represents the model that the report will stand for - report_type:- Type of report. We have many types of reports - Name:- It is a mandatory field.

Which templating engine is used in Odoo?

QWeb is the primary templating engine used by Odoo 2. It is an XML templating engine 1 and used mostly to generate HTML fragments and pages. Template directives are specified as XML attributes prefixed with t- , for instance t-if for conditionals, with elements and other attributes being rendered directly.

How do I use qweb in Python?

Most Python-side uses of QWeb are in controllers (and during HTTP requests), in which case templates stored in the database (as views) can be trivially rendered by calling openerp.http.HttpRequest.render (): This automatically creates a Response object which can be returned from the controller (or further customized to suit).


2 Answers

You have to use <t t-else=""><td>bar</td></t>, take a look the documentation.

like image 142
Juan Salcedo Avatar answered Jan 03 '23 18:01

Juan Salcedo


In above lines you have closed else tag <t t-else/>

You should write as following :

<t t-if="origin != l.origin">
  <td>foo</td>
</t>
<t t-else="">
  <td>bar</td>
</t>
like image 44
Emipro Technologies Pvt. Ltd. Avatar answered Jan 03 '23 18:01

Emipro Technologies Pvt. Ltd.