我目前正在使用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>