在odoo 9中隐藏组
Hide group in odoo 9
如何用xpath expr替换(隐藏)选项卡设置中项目管理模块中的组配置?
<group string="Configuration" groups="base.group_no_one">
<field name="sequence" groups="base.group_no_one"/>
</group>
我尝试使用以下代码但出现错误:
<xpath expr="//group[@string='Configuration']" position="replace">
</xpath>
我猜你得到的错误是 ParseError
,因为你正在使用 string
属性作为 selector 在你的 XPath 表达式中,这是不允许的,因为 Odoo v9.0.
相反,您可以尝试查找 sequence
字段和 select 父字段:
<xpath expr="//field[@name='sequence']/.." position="replace">
</xpath>
但是,替换整个元素可能不是最佳解决方案,因为其他模块可能会在继承视图中使用组或序列字段,这会导致错误。更好的解决方案是使用 invisible
属性隐藏组。完整记录可能如下所示:
<record id="edit_project_inherit" model="ir.ui.view">
<field name="model">project.project</field>
<field name="inherit_id" ref="project.edit_project"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='sequence']/.." position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
</field>
</record>
如何用xpath expr替换(隐藏)选项卡设置中项目管理模块中的组配置?
<group string="Configuration" groups="base.group_no_one">
<field name="sequence" groups="base.group_no_one"/>
</group>
我尝试使用以下代码但出现错误:
<xpath expr="//group[@string='Configuration']" position="replace">
</xpath>
我猜你得到的错误是 ParseError
,因为你正在使用 string
属性作为 selector 在你的 XPath 表达式中,这是不允许的,因为 Odoo v9.0.
相反,您可以尝试查找 sequence
字段和 select 父字段:
<xpath expr="//field[@name='sequence']/.." position="replace">
</xpath>
但是,替换整个元素可能不是最佳解决方案,因为其他模块可能会在继承视图中使用组或序列字段,这会导致错误。更好的解决方案是使用 invisible
属性隐藏组。完整记录可能如下所示:
<record id="edit_project_inherit" model="ir.ui.view">
<field name="model">project.project</field>
<field name="inherit_id" ref="project.edit_project"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='sequence']/.." position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
</field>
</record>