在 Odoo 中为按钮添加树 Header

Adding Tree Header for Button in Odoo

我在树视图中添加了图标来执行一些操作,我想向这些按钮显示 header / 标签。例如,我在树视图上有两个图标,其 header 标题为空。所以我想为这些图标添加一个标题,例如“操作”。对于所有记录,如其他字段标题。

我已经为此尝试了 link 并且在我的情况下我确实想要相同的但对我没有用。这里is the link.

这是我在实现代码时得到的截图。它在图标本身而不是树 header.

中显示字符串

节点标记属性将设置为 button_groupstringclass 属性将在子属性中可用。

尝试将 _renderHeaderCell 更改为:

_renderHeaderCell: function (node) {
    const $th = this._super.apply(this, arguments);
    if (node.tag === 'button_group' && node.children && node.children[0].attrs.class === "custom_identifier"){
        $th.text(node.children[0].attrs.string)
        .attr('tabindex', -1);
    }
    return $th;
},