2017-07-11 4 views
4
<openerp> 
<data> 

    <template id="report_invoice_document" inherit_id="account.report_invoice_document"> 

     <xpath expr="//span[@t-field='t.amount']" position="after"> 
      <span t-field="t.note"/> 
     </xpath> 
     </template> 
    </data> 
</openerp> 

Ich fügte Feld zu Rechnung Bericht innerhalb der Steuertabelle hinzu. aber wie kann ich Steuertabelle nur sichtbar machen, wenn es ein Notizfeld gibt, und ausblenden, wenn die Notiz leer ist.Konto Rechnung Bericht

Ich versuche etwas mit t-wenn aber mein Ziel ist es, Steuertabelle zu zeigen, um es nicht zu verstecken, wenn Notizfeld nicht empy ist. Gibt es irgendeine Art von T-Ifnot?

<xpath expr="//span[@t-field='t.amount']/../../../../thead/tr" position="replace"> 
       <th t-if="o.notes" 

      </xpath> 

Antwort

0

Hallo An ..,

beste Lern ​​Tutorial

Wenn Sie irgendwelche Arten von Bedingung verwenden möchten, so QWeb bietet viele Arten von eingebauten Funktionen ist. Weitere Informationen zum Lesen Ihrer untenstehenden Link,
1) https://www.odoo.com/documentation/8.0/reference/qweb.html

Lösung

Akontorechnung base/odoo Tabelle unten ist,

<div class="row" t-if="len(o.tax_line_ids) > 0"> 
    <div class="col-xs-6"> 
     <table class="table table-condensed"> 
     <thead> 
      <tr> 
       <th>Tax</th> 
       <th class="text-right">Base</th> 
       <th class="text-right">Amount</th> 
      </tr> 
     </thead> 
     <tbody> 
      <tr t-foreach="o.tax_line_ids" t-as="t"> 
       <td><span t-field="t.tax_id.description"/></td> 
       <td class="text-right"> 
        <span t-field="t.base" t-options='{"widget": "monetary", "display_currency": o.currency_id}'/> 
       </td> 
       <td class="text-right"> 
        <span t-field="t.amount" t-options='{"widget": "monetary", "display_currency": o.currency_id}'/> 
       </td> 
      </tr> 
     </tbody> 
     </table> 
    </div> 
</div> 

Jetzt möchten Sie die Tabelle zeigen, wenn t.note Feld nicht leer ist so odoo XML bietet, wenn Bedingung, alles zu überprüfen.

Nun versuchen, diesen Code unten für Ihr Problem,

<openerp> 
    <data> 
     <template id="report_invoice_document" inherit_id="account.report_invoice_document"> 
     <xpath expr="//span[@t-field='t.amount']" position="after"> 
      <t t-if="t.note">   
       <span t-field="t.note"/> 
       <!-- For example i add one new table --> 
       <table class="table table-condensed"> 
        <thead> 
         <tr> 
         <th>Tax</th> 
         <th class="text-right">Base</th> 
         <th class="text-right">Amount</th> 
         </tr> 
        </thead> 
        <tbody> 
         <tr t-foreach="o.tax_line_ids" t-as="t"> 
         <td><span t-field="t.name"/></td> 
         <td class="text-right"> 
          <span t-field="t.base" 
          t-field-options='{"widget": "monetary", "display_currency": "o.currency_id"}'/> 
         </td> 
         <td class="text-right"> 
          <span t-field="t.amount" 
          t-field-options='{"widget": "monetary", "display_currency": "o.currency_id"}'/> 
         </td> 
         </tr> 
        </tbody> 
       </table> 

      </t> 
      <t t-if="not t.note">   
       <!-- If empty t.note so not show tax table --> 
      </t> 
     </xpath> 
     </template> 
    </data> 
</openerp> 

Ich hoffe, meine Antwort hilfreich ist.
Wenn irgendeine Frage so kommentiert bitte.

+0

Vielen Dank An ... –

2

Ja. Wir können es mit folgendem Beispiel erreichen:

<t t-if="o.notes"> 
    <!-- Fields visible if Notes has value--> 
</t> 

<t t-if="not o.notes"> 
    <!-- Fields visible if Notes has no value--> 
</t> 

EDIT

Tisch in einem der Zustand entwerfen.

<t t-if="o.notes"> 
    <table style="border:1px solid; width:100%"> 
     <thead> 
      <tr> 
       <th></th> 
       <th></th> 
       <th></th> 
      </tr> 
     </thead> 
     <tbody> 
      <tr> 
       <td></td> 
       <td></td> 
       <td></td> 
      </tr> 
     </tbody> 
    </table> 
</t> 
+0

aber wenn ich alle Steuertabelle, nicht spezifische Felder zeigen möchte, wie kann ich das tun? –

+0

Ich habe meine Antwort bearbeitet. –