Skip to Content
Menu
This question has been flagged

In Odoo 12, 14 and 15 I have created a button next to Create/Export in List View and Kanban View, it renders and perform an action without any problem. But in Odoo 16 I am having an issue that the button is not rendering in both views.

Example List View Odoo 15:


My code is looks like this in Odoo 15:

Manifest:

"assets": {

    "web.assets_backend": [

        "/proyect_name/static/src/js/hr_list_view.js"

    ],

    'web.assets_qweb': [

        '/proyect_name/static/src/xml/hr_list_view.xml'

    ]

}


XML:

<templatesxml:space="preserve">    

    <tt-extend="ListView.buttons">

        <tt-jquery="button.o_list_export_xlsx"t-operation="after">

            <tt-if="widget.is_action_enabled('export_xlsx') and widget.isExportEnable">                                  <buttonid="list_view_test" t-if="widget.modelName == 'hr.employee'"type="button"class="btn btn-secondary oe_export_test o_list_export_xlsx open_wizard_action_kanban oe_highlight">Testbutton>

            t>

        t>

    t>

templates>


Javascript:

odoo.define('export_ins.print_ins', function (require) {

    "use strict";

    var ListController = require('web.ListController');

    var rpc = require('web.rpc'); 

    ListController.include({

        renderButtons: function ($node) {

            this._super.apply(this, arguments);

            if (this.modelName === "hr.employee" && this.$buttons) {

                this.$buttons.find('.oe_export_test').click(this.proxy('action_def'));  

            }

        },

        action_def: function (ev) {

            varself = this;

            returnrpc.query({model:'hr.employee'method:'odoo_button_click_test'

            },{

                shadow:true

            }).then(function (res) {

                returnself.do_action(res)

            }).catch(function (error) {

                console.log(this, error.message.data.message);

            });

        },

    });

});


How can I perform the same rendering and action but in Odoo 16?


Thanks for the response!

Avatar
Discard
Best Answer

For odoo16 Follow this tutorial 

www.cybrosys.com/blog/how-to-add-a-create-button-near-tree-kanban-view-in-odoo-15

But put your xml and js files in assets_backend bundle
and then change o_list_button_button to o_list_button_add


 

<t t-extend="ListView.buttons" t-name="some_unique_name">
        <t t-jquery="button.o_list_button_add" t-operation="after">
            <button type="button" class="btn btn-primary open_wizard_action">
                    Open Wizard
            </button>
        </t>
    </t>


       
           
       
   

Avatar
Discard
Best Answer

Hi,
In Odoo 16 the qweb templates are loaded in the assets_backend. We don't have web.assets_qweb in 16.
Try by removing the assets_qweb and add the path in the assets_backend.


"assets": {
"web.assets_backend": [
"/proyect_name/static/src/js/hr_list_view.js",
'/proyect_name/static/src/xml/hr_list_view.xml'
],
}


Hope this will help you

Thank you

Avatar
Discard
Author

Hello,
Thanks for the fast response.

I changed the paths to web.assets_backend but still without success, and in the browse console I am getting this message: "Views: using legacy view: qweb" and "Views: using legacy view: activity" (I don't know if it's because of my code) although I removed web.assets_qweb and changed to web.assets_backend. And at this point I don't what could be the problem.

Regards!

Best Answer

Here is the complete code for creating a button in Odoo 16 List View and Kanban View:

Manifest:

"assets": {

"web.assets_backend": [

    "/proyect_name/static/src/js/hr_list_view.js"

],

'web.assets_qweb': [

    '/proyect_name/static/src/xml/hr_list_view.xml'

]

}

XML:

"ListView.buttons">

    "button.o_list_export_xlsx" t-operation="after">

        if="widget.is_action_enabled('export_xlsx') and widget.isExportEnable">                                  

templates>

Javascript:

odoo.define('export_ins.print_ins', function (require) {

use strict"; var ListController = require('web.ListController'); var rpc = require('web.rpc'); ListController.include({ renderButtons: function ($node) { this._super.apply(this, arguments); if (this.modelName === "hr.employee" && this.$buttons) { this.$buttons.find('.oe_export_test').click(this.proxy('action_def')); } }, action_def: function (ev) { var self = this; return rpc.query({model:'hr.employee', method:'odoo_button_click_test' },{ shadow:true }).then(function (res) { return self.do_action(res) }).catch(function (error) {...........

Avatar
Discard
Author

Hi Ashish. I don't know if you mistakely copy the wrong code? It is because the code is like I shared for the question, or is there any difference?

Thanks for the response and help!

Regards

Related Posts Replies Views Activity
1
May 24
1909
1
Aug 20
8522
2
Jun 20
3483
2
Jul 19
8417
1
Jul 17
2825