Account Invoice Report

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

I added a field to the account report inside the tax table. but how can I make the tax table visible only if there is a note field and hide if the note is empty.

I am trying to do something with t-if, but my goal is to show the tax table so that it does not hide it when the note field is not empy. is there any type of t-ifnot?

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

            </xpath>
+4
source share
2 answers

Hello An ..,

The best tutorial on learning

, QWeb . ,
1) https://www.odoo.com/documentation/8.0/reference/qweb.html

-/ odoo ,

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

, t.note , odoo XML -.

,

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

, . - , .

0

. :

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

.

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

Source: https://habr.com/ru/post/1681195/


All Articles