Odoo Help


How to put a javascript code to onclick event Odoo 8.0

on 3/13/17, 12:02 PM 873 views

I already searched a lot of posts, here(DOCS and Forum) and in the stack overflow, but i didn't get any example that works. What i want to do is very simple in fact. I need to put a javascript code to a button onclick event, in the button that already exists. All my attempts have failed. I think that my js code runs before right time, because it's always runs, so the HTML element still doesn't exists and nothing is added to element when it is loaded. 

One of a many ways that i have tried bellow:

    "use strict";
    var _t = openerp._t;
    var _lt = openerp._lt;
    var QWeb = openerp.qweb;
    var oepetstore = openerp.oepetstore = {};
    oepetstore.Test = openerp.Widget.extend({
        events: {
            // events binding example
            "click .button_test": "myFunctionHandler",
        myFunctionHandler: function(){
            alert('ok from button!');
        start: function() {
            alert('ok!'); //this code always runs
    var pet = new oepetstore.Test();
    return oepetstore;

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.


Odoo Training Center

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

Test it now

Question tools

1 follower(s)


Asked: 3/13/17, 12:02 PM
Seen: 873 times
Last updated: 3/13/17, 4:18 PM