Skip to Content
Menu
This question has been flagged
1 Reply
9403 Views

In Odoo when you have an xpath you can add "attrs" to a field invisible, when a condition is met. This works fine.

I have a field DISCOUNT that i want to display on INVOICE/QUOTATION report only if one of the products hold a DISCOUNT value more than 0.0 (i.e - that product has a discount given to it

CODE:

    <td style="border: 0.5px solid black;background-color:#E6E6E6;">
        <span t-field="l.total_discount" /> 
    </td>

I want to add:

    attrs="{'invisible': [('total_discount','=',0.0)]}"

But i dont know if this is the correct code above.

Normally, this code should hide all tables of discount if they all equal zero (there's no use of placing a discount block if discount is zero)

Please let me know if am somewhat unclear, in any aspect.

Thanks alot.!

Avatar
Discard
Best Answer

Hi,

 In QWEB report you can use the t-if statement like this.

<td style="border: 0.5px solid black;background-color:#E6E6E6;">

<span t-if="l.total_discount != 0" t-field="l.total_discount" />

</td>

Best regards.

Avatar
Discard
Related Posts Replies Views Activity
1
Jan 23
1322
3
Aug 20
4023
0
Feb 18
1659
0
Oct 17
4118
0
Apr 16
3387