Hi, I just want to ask how to add a link button next to Add an Item in tree view.
Ex:
Column Names
Add an Item My Function
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hi, I just want to ask how to add a link button next to Add an Item in tree view.
Ex:
Column Names
Add an Item My Function
This is very specific to what need to be done when the user clic on that button, also the "Add an Item" link is related to One2many and Many2many fields in a form, and there should be a way to restrict when the button is needed because if not it will be applying for all those field widgets that get the extension.
Let's show how could be done as a draft
openerp.your_module = function (instance) {
instance.web.form.One2ManyList.include({
pad_table_to: function (count){
var self = this;
var res = this._super(count);
this.$current.find('.oe_form_field_one2many_list_row_add').append(
$('<a>', {href: '#'}).text(_t("Filter item"))
.mousedown(function () {
if (self.view.editor.is_editing()) {
self.view.__ignore_blur = true;
}
})
.click(function (e) {
e.preventDefault();
e.stopPropagation();
if (self.view.editor.form.__blur_timeout) {
clearTimeout(self.view.editor.form.__blur_timeout);
self.view.editor.form.__blur_timeout = false;
}
self.view.ensure_saved().done(function () {
//run your js code here
});
})
);
}
})
};
To do it for the Many2many fields just change:
instance.web.form.One2ManyList by instance.web.form.Many2ManyList
.oe_form_field_one2many_list_row_add by .oe_form_field_many2many_list_row_add
Also you will need to change your_module with your module name and add this js file to be loaded by the assets in the backend in an xml file like:
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="assets_backend" name="my js assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/your_module/static/src/js/file.js"></script>
</xpath>
</template>
</data>
</openerp>
This put the link as clickable to run some js code but I think that this is just the peak of the iceberg but perhaps could help you and others
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
0
Jul 16
|
3186 | ||
|
1
Jul 16
|
2693 | ||
|
2
Apr 24
|
577 | ||
|
1
Aug 23
|
12546 | ||
change password
Solved
|
|
1
Aug 23
|
11039 |