无法克隆未定义的模板 ‘ListView.buttons’ 以创建

huangapple go评论80阅读模式
英文:

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

问题

在Odoo 16中,我无法在列表视图的顶部添加按钮。我看过网上关于这个问题的几个帖子,但都没有解决方案。请帮我找到解决这个问题的正确方向。

受影响的版本:

16 - 从存储库获取的最新版本

视频/截图链接(可选):

https://monosnap.com/file/zyMHtPbDvhMmtryBeXON0dM8hnQ4WQ

复现步骤:

  1. 创建一个新模块,并添加一些模型。
  2. 想要扩展 ListView.buttons 并添加额外的按钮。让我们来做!
  3. 创建一个名为 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. __manifest__.py 中添加以下代码块:
'assets': {
    'web.assets_backend': [
        'static/src/xml/my_buttons.xml',
    ],
},

当前行为:

Odoo 系统返回一个错误:

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

期望行为:

在每个树/列表视图中都会显示带有文本“Jump1”的按钮。

英文:

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

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
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;templates&gt;
    &lt;t t-extend=&quot;ListView.buttons&quot; t-name=&quot;my_button_extension.buttons&quot;&gt;
        &lt;t t-jquery=&quot;button.o_list_button_add&quot; t-operation=&quot;after&quot;&gt;
            &lt;button class=&quot;btn btn-primary import_your_action&quot;&gt;
                Jump1
            &lt;/button&gt;
        &lt;/t&gt;
    &lt;/t&gt;
&lt;/templates&gt;
  1. In __manifest__.py add the following block of code:
    &#39;assets&#39;: {
        &#39;web.assets_backend&#39;: [
            &#39;static/src/xml/my_buttons.xml&#39;,
        ],
    },

Current behavior:

Odoo system returns an error:

UncaughtPromiseError
Uncaught Promise &gt; QWeb2: Can&#39;t clone undefined template &#39;ListView.buttons&#39; to create &#39;my_button_extension.buttons&#39;
Error: QWeb2: Can&#39;t clone undefined template &#39;ListView.buttons&#39; to create &#39;my_button_extension.buttons&#39;
    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".

答案1

得分: 1

与企业模块 hr_expense 和您的方法唯一真正的区别,我能看到的是资产文件的文件路径。我选择了模块 hr_expense,因为它扩展了列表视图按钮 无法克隆未定义的模板 ‘ListView.buttons’ 以创建

在Odoo的清单中,路径以模块的名称开头:

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

另一个提示:将 web 模块添加为清单的依赖项。

英文:

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 无法克隆未定义的模板 ‘ListView.buttons’ 以创建

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

    &#39;assets&#39;: {
        &#39;web.assets_backend&#39;: [
            &#39;my_button_extension/static/src/xml/my_buttons.xml&#39;,
        ],
    },

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

huangapple
  • 本文由 发表于 2023年6月26日 20:10:27
  • 转载请务必保留本文链接:https://go.coder-hub.com/76556555.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定