How to Add a New Button like Create Button in the tree view header
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ờ
Hi,
For adding button in tree view in odoo 15, see: https://www.youtube.com/watch?v=R8eG6uOxHKw
Thanks
Hello
check below link may help you
https://www.odoo.com/forum/help-1/how-to-add-a-button-field-on-the-header-of-tree-view-105285
I understand your question and yes the code is changed in V15.
I tried adding a button on sale order list view and I could achive it using below code.
Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari
Js file code:
function ccButton() {
if (this.$buttons) {
var self = this;
this.$buttons.on('click', '.o_button_custom', function () {
self.do_action({
name: 'Generate Leads',
type: 'ir.actions.act_window',
res_model: 'sale.order',
target: 'new',
views: [[false, 'form']],
});
});
}
}
var cListController = ListController.extend({
willStart: function() {
var self = this;
// var ready = self.buttons_template = 'CustListView.buttons';
var ready = this.getSession().user_has_group('sales_team.group_sale_manager')
.then(function (is_sale_manager) {
if (is_sale_manager) {
self.buttons_template = 'CustListView.buttons';
}
});
return Promise.all([this._super.apply(this, arguments), ready]);
},
renderButtons: function () {
this._super.apply(this, arguments);
ccButton.apply(this, arguments);
}
});
var CustListView = ListView.extend({
config: _.extend({}, ListView.prototype.config, {
Controller: cListController,
}),
});
viewRegistry.add('cust_tree', CustListView);
Xml file code :
<field name="name">sale.order.tree</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_quotation_tree_with_onboarding"/>
<field name="mode">primary</field>
<field name="arch" type="xml">
<xpath expr="//tree" position="attributes">
<attribute name="js_class">cust_tree</attribute>
</xpath>
</field>
</record>
</odoo>
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ý
Niyas Raphy thanks for your reply
this video is very helpful but I want to add a button that allows visible, not visible only when I select a record