Search code examples
odooodoo-16

odoo16 - Can't clone undefined template 'ListView.buttons' to create


In odoo 16 I cannot add buttons to the top of list view. I have seen several treads about this issue online - all with no solution. please help me with right direction to solve this issue.

Impacted versions:

16 - latest version from repo

Video/Screenshot link (optional):

https://monosnap.com/file/zyMHtPbDvhMmtryBeXON0dM8hnQ4WQ

Steps to reproduce:

  1. Create a new module with some models
  2. Have a desire to extend ListView.buttons with extra buttons. Let's do it!
  3. Create a file mu_module/static/src/xml/my_buttons.xml
<?xml version="1.0" encoding="UTF-8"?>
<templates>
    <t t-extend="ListView.buttons" t-name="my_button_extension.buttons">
        <t t-jquery="button.o_list_button_add" t-operation="after">
            <button class="btn btn-primary import_your_action">
                Jump1
            </button>
        </t>
    </t>
</templates>
  1. In __manifest__.py add the following block of code:
    'assets': {
        'web.assets_backend': [
            'static/src/xml/my_buttons.xml',
        ],
    },

Current behavior:

Odoo system returns an error:

UncaughtPromiseError
Uncaught Promise > QWeb2: Can't clone undefined template 'ListView.buttons' to create 'my_button_extension.buttons'
Error: QWeb2: Can't clone undefined template 'ListView.buttons' to create 'my_button_extension.buttons'
    at Object.exception (http://localhost:8069/web/assets/20-aacf356/web.assets_common.min.js:5526:7)
    at Engine.add_template (http://localhost:8069/web/assets/20-aacf356/web.assets_common.min.js:5542:361)
    at http://localhost:8069/web/assets/20-aacf356/web.assets_common.min.js:5601:97

Expected behavior:

In every tree/list view will appear button wuth text "Jump1".


Solution

  • The only real difference between the enterprise module hr_expense and your approach i can see, is the file path for the assets. I took the module hr_expense because it is extending the listview buttons ;-)

    In Odoo's manifest the paths start with the module's name:

        'assets': {
            'web.assets_backend': [
                'my_button_extension/static/src/xml/my_buttons.xml',
            ],
        },
    

    Another hint: add web module as dependency to your manifest.