2017-01-19 2 views
1

아래의 qweb 보고서 설정 조건은 0 인 경우 할인이 0이면 할인 0입니다.오도 9 qweb 플로팅 0으로 나누기

<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> 

할인 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> 

어떤 간단한 해결책 인 경우?

답변

2

qweb 템플릿 엔진의 경우 official documentation을 살펴보십시오. 조건이 귀하의 경우에는

t-if라는 이름의 구문이 작동합니다 있습니다 : 당신이 사용해야 할 것입니다, 그래서 더 다른 운영자가 아직 없습니다

<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> 

두 개의 연속 if

편집 : v10에서는 t-else 연산자를 사용할 수 있습니다.