This question has been flagged
3 Replies
3439 Views

Hello together,

in the invoice report I want implement the following logic:

<span t-if="o.x_onlineId != ''">

  <div class="col-xs-2" style="width:180px"> 

  <strong>Web Id</strong>

   <p t-field="o.x_onlineId"/> 

  </div> 

</span>

The problem is that the if condition do not work. The field "Web Id" is always printed in the invoice even the fiel x_onlineId is empty. 

I have already tested the following syntax 

<span t-if=" not o.x_onlineId == ''">

It also did not work.

The question is how it is possible to check for an empty value in a field?

Has someone an idea.

Thanks in advanced

cakbulut


Avatar
Discard
Best Answer

Field Text may be empty (string with length zero) or may be set to False or None. In all cases the best way in python is to test falsy

<span t-if="o.x_onlineId">

see python documentation: https://docs.python.org/2/library/stdtypes.html#truth-value-testing



Avatar
Discard
Best Answer

Try this:

<span t-if="o.x_onlineId">

<div class="col-xs-2" style="width:180px"> 

<strong>Web Id</strong>

<p t-field="o.x_onlineId"/> 

 </div> 

</span>

Avatar
Discard
Author Best Answer

Thanks a lot. Worked fine for me.

Avatar
Discard