Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată

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?

Imagine profil
Abandonează
Autor Cel mai bun răspuns

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
    }
};
 
Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
0
feb. 21
3091
0
feb. 18
2489
5
dec. 17
5466
3
iun. 17
5105
0
ian. 16
3302