odoo10在顶部“创建”按钮附加增加自定义按钮
来源:互联网 发布:淘宝定制商品怎么拍 编辑:程序博客网 时间:2024/05/30 23:03
HOW TO ADD BUTTON IN TREE VIEW HEADER NEAR “CREATE” AND “IMPORT” BUTTONSODOO10
来自:https://supportuae.wordpress.com/2017/09/06/how-to-add-button-in-tree-view-header-near-create-and-import-buttons-odoo10/
1). I create some js script (tree_menu/static/src/js/tree_view_button.js) with click listener for my button :
odoo.define(
'tree_menu.tree_view_button'
,
function
(require){
"use strict"
;
var
core = require(
'web.core'
);
var
ListView = require(
'web.ListView'
);
var
QWeb = core.qweb;
ListView.include({
render_buttons:
function
($node) {
var
self =
this
;
this
._super($node);
this
.$buttons.find(
'.o_list_tender_button_create'
).click(
this
.proxy(
'tree_view_action'
));
},
tree_view_action:
function
() {
this
.do_action({
type:
"ir.actions.act_window"
,
name:
"product"
,
res_model:
"product.template"
,
views: [[
false
,
'form'
]],
target:
'current'
,
view_type :
'form'
,
view_mode :
'form'
,
flags: {
'form'
: {
'action_buttons'
:
true
,
'options'
: {
'mode'
:
'edit'
}}}
});
return
{
'type'
:
'ir.actions.client'
,
'tag'
:
'reload'
, } }
});
});
2). After that, create tree_menu/static/src/xml/tree_view_button.xml with the template, which replaces “Create” button if I use project.project model
<?
xml
version
=
"1.0"
encoding
=
"UTF-8"
?>
<
template
id
=
"template"
xml:space
=
"preserve"
>
&l
t
;t
t-extend
=
"ListView.buttons"
>
&l
t
;t
t-jquery
=
"button.o_list_button_add"
t-operation
=
"replace"
>
<
button
t-if
=
"widget.model == 'purchase.order'"
class
=
"btn btn-primary btn-sm o_list_tender_button_create"
type
=
"button"
>Create Tender</
button
>
<
button
t-if
=
"widget.model != 'purchase.order'"
class
=
"btn btn-primary btn-sm o_list_button_add"
type
=
"button"
>Create</
button
>
&l
t
;/t>
&l
t
;/t>
</
template
>
3). After that, add js script in web.asset_backend (Create file tree_menu/views/tree_view_asset.xml)
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
odoo
>
<
data
>
<
template
id
=
"assets_backend"
name
=
"tree view menu"
inherit_id
=
"web.assets_backend"
>
<
xpath
expr
=
"."
position
=
"inside"
>
<
script
type
=
"text/javascript"
src
=
"/tree_menu/static/src/js/tree_view_button.js"
></
script
>
</
xpath
>
</
template
>
</
data
>
</
odoo
>
4). And finally, add in __manifest__.py section ‘qweb’ for ‘qweb’: [‘static/src/xml/tree_view_button.xml’], and place file views/project.xml in ‘data’ section.
{
'name': 'odoo10 Tree View JS Menu',
'version': '1.0',
'category': 'General',
'summary': 'odoo10 Tree View JS Menu',
'description': """ odoo10 Tree View JS Menu """,
'author': 'Ananthu',
'website': 'http://www.codersfort.com',
'depends': ['base','purchase','web'],
'data':[
'views/tree_view_asset.xml',
],
'qweb': ['static/src/xml/tree_view_button.xml'],
'demo': [],
'installable': True,
'application': True,
'auto_install': False,
}
- odoo10在顶部“创建”按钮附加增加自定义按钮
- ueditor 增加自定义按钮
- 在REPORT标准应用工具条上增加自定义按钮
- vc创建自定义按钮
- ALV在标准按钮上增加自定义按钮,并实现文本及功能互相切换
- UITableView 状态栏返回顶部 和自定义按钮返回顶部
- ECharts自定义toolbox中增加自定义按钮
- 在网页中添加 “返回顶部”按钮
- Android在顶部标题栏添加按钮
- 增加自定义按钮风格功能! – 社会化分享按钮
- WPF创建自定义按钮[1]
- WPF创建自定义按钮[2]
- Blend创建一个自定义按钮
- DXUT中增加自定义按钮控件
- (转)FCKeditor如何自定义增加工具栏按钮
- FUN ALV TOOLBAR 增加自定义按钮
- FUN ALV TOOLBAR 增加自定义按钮
- iOS Tabbar上增加一个自定义按钮
- My first day in CSDN
- sql面试题(学生表_课程表_成绩表)
- cordova angular 中动态增加的 js和html代码 不可用的解决方案
- Swift开发iOS App学习笔记(一)---AppIcon & LaunchScreen
- ES6 数组相关操作
- odoo10在顶部“创建”按钮附加增加自定义按钮
- JAVA中循环删除list中元素的方法总结
- vmware中ubuntu通过主机无线进行上网,但是ping不通
- JavaScript的null和undefined的区别
- 判断有向图是否存在环的2种方法(深度遍历,拓扑排序)
- 机器学习常见问答
- PHP7编译安装openssl.so模块
- GitHub注册、创建Repository、搭建基于GitHub的个人网页
- APP开发实战179-Activity消息路由