为什么我的代码无法更改按钮 odoo 15 上的属性



我正在使用odoo 15,我想改变属性按钮上的股票。数量树视图可编辑。对于像这样的代码:

<xpath expr="//button[@name='action_apply_inventory']" position="attributes">
<attribute name="attrs">{'invisible': ['|', ('inventory_quantity_set', '=', False), ('is_approved', '=', False)]}</attribute>
<attribute name="groups">base.group_system,pitik_base_farm.group_finance_head</attribute>
<attribute name="string">Submit</attribute>
</xpath>

但是这段代码不起作用,不影响视图

输入图片描述

输入图片描述

您正在使用invisible属性域中的is_approved字段,但此字段在视图中不存在。您需要将它添加到视图中才能在域中使用它。

<record id="view_stock_quant_tree_inventory_editable_inherit_custom" model="ir.ui.view">
<field name="name">stock.quant.inventory.tree.editable.inherit.custom</field>
<field name="model">stock.quant</field>
<field name="inherit_id" ref="stock.view_stock_quant_tree_inventory_editable"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='inventory_quantity_set']" position="after">
<field name="is_approved" invisible="1"/>
</xpath>
<xpath expr="//button[@name='action_apply_inventory']" position="attributes">
<attribute name="attrs">{'invisible': ['|', ('inventory_quantity_set', '=', False), ('is_approved', '=',
False)]}
</attribute>
<attribute name="groups">base.group_system,pitik_base_farm.group_finance_head</attribute>
<attribute name="string">Submit</attribute>
</xpath>
</field>
</record>

最新更新