buttontreeviewodooodoo-14

Adding Tree Header for Button in Odoo


I have added icons in tree view to perform some actions and i want to show header / label to these buttons. For example, I have two icons on tree view and its header title is empty. So I want to add a single heading for these icons which will be "Action" for eg. for all the records like other fields heading.

I have tried a link for this and exactly I want the same in my case but didn't worked for me. Here is the link.

enter image description here

Here is the screenshot of what I am getting while implementing the code. It is displaying the string in the icon itself but not in the tree header.


Solution

  • The node tag attribute will be set to button_group, the string and class attributes will be available in the child attributes.

    Try to change the _renderHeaderCell to:

    _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;
    },