我想做这样的事情: -
<record id="view_form" model="ir.ui.view">
<field name="name">module.form</field>
<field name="model">module.form</field>
<field name="inherit_id" ref="another_module.view_form"/>
<field name="priority" eval="20"/>
<field name="arch" type="xml">
<xpath expr="//notebook" position="replace">
<notebook t-if="context.get('no_error', False)">
<page name="A" string="A">
<group>
<field name='save'/>
</group>
</page>
</notebook>
<notebook t-if="not context.get('no_error', False)">
<page name="A" string="A">
<group>
<field name='save' widget="my_widget"/>
</group>
</page>
</notebook>
</xpath>
</field>
</record>
但是我在UI / View中获得了两个笔记本
我尝试使用t-esc打印该值,但我没有得到任何 Value .
是可以做这样的事情还是我们可以在xpath中使用上下文?
1 回答
您不能在普通表单视图上使用qweb . 这是模板和报告
方法0
但是你可以创建一个辅助字段,例如它可能是一个计算字段
那么XML视图应该是:
请记住,您不能在同一表格中使用相同的项目两次 . 因此,如果要显示
<field name='save'/>
或<field name='save' widget="my_widget"/>
,则应为每个窗口创建一个独立的窗体视图 .方法1
或者您可以尝试使用应在模型中定义的方法
fields_view_get
修改视图,类似这样(我还没有测试):