5

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?

Naglis
  • 2,583
  • 1
  • 19
  • 24
M.E.
  • 4,955
  • 4
  • 49
  • 128

4 Answers4

10

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

Juan Salcedo
  • 1,598
  • 1
  • 16
  • 28
4

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>
Naglis
  • 2,583
  • 1
  • 19
  • 24
2

You also try t-elif :

<t t-if="origin != l.origin">
    <td>foo</td>
</t>
<t t-elif="">
    <td>bar</td>
</t>
Naglis
  • 2,583
  • 1
  • 19
  • 24
Jignasha Royala
  • 1,032
  • 10
  • 27
0

Note for those who are looking for similar problem, t-else is only added in Odoo 10.

So, for Odoo < 10, negation of t-if should be used instead.

<t t-if="condition">
</t>
<t t-if="not condition">
</t>

For Odoo >= 10,

<t t-if="condition">
</t>
<t t-else="">
</t>
Pyae
  • 500
  • 1
  • 4
  • 15