Reputation: 2358
How in below qweb report set condition when is discount 0 if discount not 0 work fine.
<td class="text-right">
<span t-esc="l.price_unit-(l.price_unit/l.discount)"/>
</td>
<td class="text-right">
<span t-field="l.quantity"/>
</td>
<td class="text-right">
<span t-field="l.price_unit"/>
</td>
<td t-if="display_discount" class="text-right" groups="sale.group_discount_per_so_line">
<span t-field="l.discount"/>
</td>
<td class="text-right">
<span t-esc="l.price_unit-(l.price_unit/l.discount)"/>
</td>
</tr>
If discount is 0
<td class="text-right">
<span t-esc="l.price_unit"/>
</td>
elif
<td class="text-right">
<span t-esc="l.price_unit-(l.price_unit/l.discount)"/>
</td>
Any simple solution?
Upvotes: 1
Views: 673
Reputation: 3747
Please take a look at the official documentation for the qweb templating engine. There is a conditional construct there named t-if
In your case this should work:
<t t-if="l.discount == 0">
<td class="text-right">
<span t-esc="l.price_unit"/>
</td>
</t>
<t t-if="l.discount != 0">
<td class="text-right">
<span t-esc="l.price_unit-(l.price_unit/l.discount)"/>
</td>
</t>
There is no else operator yet so you will have to use two successive if
s
Edit: On v10 a t-else
operator has been created which you can use.
Upvotes: 2