콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다

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?

아바타
취소
작성자 베스트 답변

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
    }
};
 
아바타
취소
관련 게시물 답글 화면 활동
0
2월 21
3483
0
2월 18
2767
5
12월 17
5763
3
6월 17
5548
0
1월 16
3599