Odoo 16 使用XPath设置字段为只读
我现在正在使用Odoo 16,我创建了一个自定义字段,想把这个字段设置为只读。这个只读字段应该只在非管理员用户登录时显示。
这是我最初的代码:
<odoo>
<data>
<record id="product_template_only_form_view" model="ir.ui.view">
<field name="name">product.template.product.form</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_only_form_view"/>
<field name="arch" type="xml">
<xpath expr="//group[@name='group_general']" position="inside">
<field name="recommanded_price" string="Recommended Price" readonly="1" groups="base.group_system"/>
</xpath>
</field>
</record>
</data>
</odoo>
我尝试了什么?
<odoo>
<data>
<record id="product_template_only_form_view" model="ir.ui.view">
<field name="name">product.template.product.form</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_only_form_view"/>
<field name="arch" type="xml">
<xpath expr="//group[@name='group_general']" position="inside">
<field name="recommanded_price" string="Recommended Price"
attrs="{'readonly': [('groups', 'not in', ['base.group_system'])]}"
/>
</xpath>
</field>
</record>
</data>
</odoo>
1 个回答
暂无回答