如何在Xml中根据条件使字段不可见.Odoo 14



我想在account.payment.register向导中隐藏继承视图中的字段。

Here I try is

<record id="view_payment_register_form_inherit" model="ir.ui.view">
<field name="name">account.payment.register.form.inherit.payment.test</field>
<field name="model">account.payment.register</field>
<field name="inherit_id" ref="account.view_account_payment_register_form"/>
<field name="arch" type="xml">
<field name="communication" position="after">
<field name="new_field"  attrs="{'invisible': [('journal_id.type', '=', 'bank')]}" />
</field>
</field>
</record>

更新模块时出错。

f(rec)
File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 685, in _tag_root
)) from e
Exception
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/odoo/http.py", line 639, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 315, in _handle_exception
raise exception.with_traceback(None) from new_cause
payment.xml:5, near
_inherit = 'account.payment.register'
type = fields.selection(related='journal_id.type')

试试这个。

<record id="view_payment_register_form_inherit" model="ir.ui.view">
<field name="name">account.payment.register.form.inherit.payment.test</field>
<field name="model">account.payment.register</field>
<field name="inherit_id" ref="account.view_account_payment_register_form"/>
<field name="arch" type="xml">
<xpath expr="//group/field[@name='communication']" position="after">
<field name="new_field"  attrs="{'invisible': [('type', '=', 'bank')]}" />
</xpath>
</field>
</record>

如果仍然得到错误,给我看日志文件

相关内容

  • 没有找到相关文章

最新更新