我正在 Odoo 中开发一个模块。我需要更改发票报告以添加一些详细信息。
我使用带有位置属性的 xpath 并检查是否链接了一个事件来隐藏默认表。
<template id="my_invoice" inherit_id="account.report_invoice_document">
<xpath expr="//div[@class='page']/table[@class='table table-condensed']" position="attributes">
<attribute t-if="o.affair_id" name="class">hidden</attribute>
</xpath>
</template>
Run Code Online (Sandbox Code Playgroud)
这是行不通的。即使发票未链接到事务,默认表也隐藏在每个发票中。
我不明白,因为条件适用于我的第二个模板。
<template id="my_invoice2" inherit_id="account.report_invoice_document">
<xpath expr="//div[@class='page']/div[@class='row mt32 mb32']" position="after">
<t t-if="o.affair_id">
<!-- table with my additional detail -->
</t>
</xpath>
</template>
Run Code Online (Sandbox Code Playgroud)
对不起我的英语不好。我正在学习它。
试试这个:
<attribute name="t-att-style">'display: none;' if o.affair_id else ''</attribute>
Run Code Online (Sandbox Code Playgroud)
或者甚至这个也是:
<attribute name="t-att-class">'hidden' if o.affair_id else ''</attribute>
Run Code Online (Sandbox Code Playgroud)
它可能对您的情况有所帮助。
| 归档时间: |
|
| 查看次数: |
3693 次 |
| 最近记录: |