英文:
odoo16 - Can't clone undefined template 'ListView.buttons' to create
问题
在Odoo 16中,我无法在列表视图的顶部添加按钮。我看过网上关于这个问题的几个帖子,但都没有解决方案。请帮我找到解决这个问题的正确方向。
受影响的版本:
16 - 从存储库获取的最新版本
视频/截图链接(可选):
https://monosnap.com/file/zyMHtPbDvhMmtryBeXON0dM8hnQ4WQ
复现步骤:
- 创建一个新模块,并添加一些模型。
- 想要扩展
ListView.buttons
并添加额外的按钮。让我们来做! - 创建一个名为
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>
- 在
__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
Video/Screenshot link (optional):
https://monosnap.com/file/zyMHtPbDvhMmtryBeXON0dM8hnQ4WQ
Steps to reproduce:
- Create a new module with some models
- Have a desire to extend
ListView.buttons
with extra buttons. Let's do it! - 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>
- 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".
答案1
得分: 1
与企业模块 hr_expense
和您的方法唯一真正的区别,我能看到的是资产文件的文件路径。我选择了模块 hr_expense
,因为它扩展了列表视图按钮
在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
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论