账户发票报告

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>

我在税中的发票报告中添加了字段 table。但是我怎样才能让税 table 只有在有注释字段时才可见,而在注释为空时隐藏。

我尝试使用 t-if 进行一些操作,但我的目标是显示税 table 在注释字段不为空时不要隐藏它。有什么t-ifnot吗?

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

            </xpath>

是的。我们可以用下面的例子来实现它:

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

编辑

在其中一种情况下设计您的table。

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

你好安..,

最佳学习教程

如果您想使用任何类型的条件,那么 QWeb 提供了许多类型的内置功能。更多信息请阅读下文 link、
1) https://www.odoo.com/documentation/8.0/reference/qweb.html

解决方案

帐户发票 base/odoo table 如下,

<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 字段不为空时显示 table,因此 odoo XML 提供 if 条件来检查任何内容。

现在试试下面的代码来解决你的问题,

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

希望我的回答对您有所帮助。
如果有任何疑问,请评论。