Odoo Help

2
9 Answers
5
Avatar

Axel Mendoza

--Axel Mendoza--
13458
| 7 8 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full-time employee trying to understand what to do and how

Reach me at aekroft@gmail.com

Axel Mendoza
8/31/15, 7:21 PM

This require to develop an extension in the template and javascript widget, like this:

You need to include a template that insert the button like:

<t t-extend="ListView.buttons">
<t t-jquery="button.oe_list_add" t-operation="after">
<button class="oe_button oe_new_button oe_highlight" type="button">New Button</button>
</t>
</t>

Next you need to extend the widget ListView like this:

instance.web.ListView.include({
    load_list: function(data) {
if (this.$buttons) {
this.$buttons.find('.oe_new_button').click(this.proxy('do_new_button')) ;
}
},
do_new_button: function () {
//implement your clic logic here  
}
});

This is an example of course

4 Comments
Daniel Kauffman
8/31/15, 8:50 PM

Like so? https://www.odoo.com/documentation/8.0/howtos/web.html

Axel Mendoza
9/1/15, 6:16 PM

see an example in the updated response

Limitless Virtual Enterprise, Andre de Kock
9/2/15, 6:47 AM

Will this code add the button for *all* tree views?

Axel Mendoza
9/2/15, 6:49 AM

Yes. But you could restrict the visibility using options for the template

1
Taha ZIADEH
4/27/18, 5:19 AM

In Odoo 11, here is how to achieve this:
Let's say we want to add special filtering functionality through a button
First create a template that is responsible of displaying the button :

<?xml version="1.0" encoding="UTF-8"?>

<template xml:space="preserve">

<t t-extend="ListView.buttons">

<t t-jquery="button.o_list_button_add" t-operation="after">

<button t-if="widget.modelName == 'your.model.name'" type="button" class="btn btn-primary btn-sm oe_filter_button" accesskey="f">

Advanced Filters

</button> 

</t>

</t>

</template>

P.S.:Don't forget to add the file containing the above template to the manifest
So far the button will be available but not functional. In order to make it functional, you have to add javascript support for its click event :

odoo.define('whatever.filter_button', function (require) {

"use strict";

var core = require('web.core');

var ListController = require('web.ListController');

ListController.include({

renderButtons: function($node) {

this._super.apply(this, arguments);

if (this.$buttons) {

let filter_button = this.$buttons.find('.oe_filter_button');

filter_button && filter_button.click(this.proxy('filter_button')) ;

}

},

filter_button: function () {

console.log('yay filter')

//implement your click logic here

}

});

})

Then, load the javascript file you wrote as a script like:

<template id="assets_backend" name="whatever_name assets" inherit_id="web.assets_backend">

<xpath expr="." position="inside">

<script src="/your_module_name/static/src/js/filter_button.js" type="text/javascript"/>

</xpath>

</template>

For further implementation details, don't hesitate to post your comments or questions :)

1
Avatar

Emipro Technologies Pvt. Ltd.

--Emipro Technologies Pvt. Ltd.--
7302
| 6 7 8
Rajkot, India
--Emipro Technologies Pvt. Ltd.--

Emipro has been providing a wide range of business solutions in the domain of ERP & eCommerce. We take pride in serving 1000s of contented customers across the globe with strong roots in the US, Europe & India. Being a Certified Odoo Gold Partner in India as well as the United States, we bring our rich professional experience and unrivaled technical competence to help our customers obtain efficient and cost-effective business solutions in Odoo. With our team of 50+ Odoo Experts and highly experienced business analysts, we serve our customers which are companies of all sizes, ranging from start-ups to large enterprises. 

Our ERP Services:

  • Business Need Analysis & GAP Analysis

  • ERP Migration

  • Odoo Consultancy

  • Odoo Implementation & Customization

  • Odoo Training & Support

  • Odoo Website & eCommerce Development

  • Odoo Integration (Marketplaces, eCommerce platforms, Shipping Carriers, Payment Gateways etc.)

Our Achievements:


Reach Us:

Website: www.emiprotechnologies.com

Email: info@emiprotechnologies.com

Skype: emiprotech

Emipro Technologies Pvt. Ltd.
9/1/15, 1:52 AM

Hello Daniel,

You can refer to account module & following files

  • /account/static/src/js/account_move_line_quickadd.js

  • /account/static/src/xml/account_move_line_quickadd.xml

This will not add the button at exact location where you wanted, but still can help you.

Hope this helps.

0
Jerry zhang
3/25/19, 4:19 PM

How do I add this button to Kanban View Header? Thanks

0
Adrian Nicorici
7/6/18, 6:11 AM

@Taha ZIADEH

In my case it did not work until i added at the end:

core.action_registry.add('product.template.custom_filter', ListController);
// return the object.
return ListController;

JS file looks like this:

odoo.define('product.template.custom_filter', function (require) {

"use strict";
console.log('something');
var core = require('web.core');
console.log('require list controller');
var ListController = require('web.ListController');
console.log('list controler: ' + ListController);
ListController.include({

renderButtons: function($node) {

this._super.apply(this, arguments);

if (this.$buttons) {

let filter_button = this.$buttons.find('.oe_filter_button');

filter_button && filter_button.click(this.proxy('filter_button')) ;

}

},

filter_button: function () {
console.log('yay filter');
}

});
console.log('registering');
core.action_registry.add('product.template.custom_filter', ListController);
// return the object.
return ListController;
})



Ask a Question
Keep Informed
3 follower(s)
About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register
Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now