从条件基础上的 One2many 字段中删除删除图标Odoo 11

问题描述

我想删除 Odoo 中布尔字段为 True 的 one2many 字段中某行的删除图标

解决方法

您需要禁用默认的删除按钮,然后创建自己的删除按钮并在其上应用您的条件:

<tree string="My Tree" delete="false">
    <field name="my_field1"/>
    <field name="my_field2"/>
    <field name="my_boolean_field"/>
    <button name="unlink"
            string="Unlink"
            type="object"
            class="btn-secondary"
            attrs="{'invisible': [('my_boolean_field','=',False)]}"
            icon="fa-trash-o"/>
</tree>

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...