I can successfully add buttons in form view header or in tree view rows, but i want add custom button in tree view header near "Create" and "Import" buttons in Odoo 8. How can i do this?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
I find solution of my problem! I replace create button if I use project.project model.
1) I create some js script (static/src/js/task_list.js) with click listener for my button :
openerp.project = function (instance){
var QWeb = openerp.web.qweb;
_t = instance.web._t;
var self = this;
openerp.web.ListView.include({
load_list: function(data) {
this._super(data);
if (this.$buttons) {
this.$buttons.find('.oe_new_button').off().click(this.proxy('do_the_job')) ;
console.log('Save & Close button method call...');
}
},
do_the_job: function () {
this.do_action({
type: "ir.actions.act_window",
name: "Создание нового проекта",
res_model: "project.project",
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 I create static/src/xml/project_button.xml with template, which replace "Create" button if I use project.project model
<?xml version="1.0" encoding="UTF-8"?>
<template id="template" xml:space="preserve">
<t t-extend="ListView.buttons">
<t t-jquery="button.oe_list_add" t-operation="replace">
<button t-if="widget.model == 'project.project'" class="oe_button oe_new_button oe_highlight" type="button">Создать новый проект</button>
<button t-if="widget.model != 'project.project'" class="oe_button oe_list_add oe_highlight" type="button">Создать</button>
</t>
</t>
</template>
3) After that I add my js script in web.asset_backend (I create file project/views/project.xml)
<?xml version="1.0" encoding="utf-8"?>
<!-- vim:fdn=3:
-->
<openerp>
<data>
<template id="assets_backend" name="project assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/project/static/src/js/task_list.js"></script>
</xpath>
</template>
</data>
</openerp>
4) And finally I add in project/\_\_openerp__.py section 'qweb' for static/src/xml/project_button.xml, 'js' for static/src/js/task_list.js and place file views/project.xml in 'data' section.
'data': [
'security/project_security.xml',
...
'views/project.xml',
],
'qweb': ['static/src/xml/project_button.xml',],
...
'js': 'static/src/js/task_list.js',
And my button successful replace old button in project.project model.
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng kýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
|
1
thg 12 24
|
4090 | ||
set default user
Đã xử lý
|
|
1
thg 11 16
|
9513 | |
|
1
thg 2 16
|
3689 | ||
|
0
thg 3 15
|
3062 | ||
|
1
thg 3 15
|
5618 |