odoo子表的列表视图,想要根据条件控制是否显示,需要在attrs中使用’column_invisible’属性,写法和attrs中的invisible属性用法一致,区别是字段需要使用父表中的字段。
示例如下:
<field name="is_vehicle_location_1_display" invisible="1"/>
<field name="electric_vehicle_line_ids">
<tree editable="bottom">
<field name="vehicle_location_1"
attrs="{'column_invisible': [('parent.父表字段名', '=', False)]}"/>
</tree>
</field>```
需要注意的是,判断条件需要使用父表字段,大概原因猜想是因为,父表只有一条数据,但是子表有多条数据,如果使用子表字段,odoo不知道以子表中那一条数据为准,所以必须使用父表中的字段作为判断条件