Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet

I need to run some client-side javascript from a button in a form view in Odoo 8. This button runs a python method which returns this dictionary:

{"type": "ir.actions.client",
 "tag": "my_module.do_something",}

do_something is defined in a .js file as follows:

openerp.my_module = function (instance) {
    instance.web.client_actions.add("my_module.do_something", "instance.my_module.Action");
    instance.my_module.Action = instance.web.Widget.extend({
        init: function() {
            // Do a lot of nice things here
        }
    });
};

Now, the javascript is loaded and executed properly, but even before launching the init function, Odoo loads a brand new, blank view, and once the javascript is over I can't get browse any other menu entry. In fact, wherever I click I get this error:

Uncaught TypeError: Cannot read property 'callbackList' of undefined

What I need instead is to run the javascript from the form view where the button belongs, without loading a new view, so both getting the javascript stuff done and leaving all callbacks and the whole environment in a good state. My gut feeling is that I shouldn't override the init funcion (or maybe the whole thing is broken, I'm quite new to Odoo client-side js) , but I couldn't find docs neither a good example to call js the way I want. Any idea to get that?

Avatar
Verwerfen
Autor Beste Antwort

I found a way to fix my issue by rewriting the js function:

openerp.my_module = function (instance) {
    instance.web.client_actions.add("my_module.do_something", "instance.my_module.action");
    instance.my_module.action = function (parent, action) {
        // Do a lot of nice things here
    }
};
 
Avatar
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
0
Feb. 21
3506
0
Feb. 18
2778
5
Dez. 17
5809
3
Juni 17
5564
0
Jan. 16
3618