【问题标题】:How to override the included function made from im_livechat.js where the function is also overriden from im_chat.js? using Odoo 8如何覆盖由 im_livechat.js 制作的包含函数,其中该函数也被 im_chat.js 覆盖?使用 Odoo 8
【发布时间】:2017-01-24 09:10:53
【问题描述】:

如何覆盖从 im_livechat.js 生成的包含函数,其中该函数也从 im_chat.js 覆盖?

例如。

im_chat.js

im_chat.Conversation = openerp.Widget.extend({
   update_fold_state: function(state){
      return new openerp.Model("im_chat.session").call("update_state", [], {"uuid" : this.get("session").uuid, "state" : state});
   },
})

im_livechat.js

openerp.im_chat.Conversation.include({
    update_fold_state: function(state){
        if(state === 'closed'){
            this.destroy();
        }else{
            if(state === 'open'){
                this.show();
            }else{
                if(this.shown){
                    state = 'fold';
                    this.hide();
                }else{
                    state = 'open';
                    this.show();
                }
            }
        }
        var session = this.get('session');
        session.state = state;
        this.set('session', session);
        openerp.set_cookie(im_livechat.COOKIE_NAME, JSON.stringify(session), 60*60);
     },
});

myjavascript.js

openerp.im_livechat.Conversation.inlcude({
    update_fold_state: function(state){
        alert("Hello World");
    },
})

我的目标:

我不想从 im_livechat.js 调用 update_fold_state 函数,而是想从 myjavascript.js 触发 update_fold_state 函数

【问题讨论】:

    标签: javascript openerp odoo-8


    【解决方案1】:

    在您的 myjavascript.js

    openerp.im_livechat.Conversation 替换为openerp.im_chat.Conversation

    openerp.im_chat.Conversation.inlcude({
        update_fold_state: function(state){
            alert("Hello World");
        },
    
    })
    

    【讨论】:

    • 嗨@KbiR,我已经尝试过了,但 odoo 仍然从 im_livechat.js 调用该函数。我想操作来自 im_livechat.js 的代码。我不想在该代码中添加一些东西。但在我自己的文件中。
    猜你喜欢
    • 1970-01-01
    • 2016-04-04
    • 1970-01-01
    • 1970-01-01
    • 2020-04-10
    • 1970-01-01
    • 2012-08-09
    • 1970-01-01
    • 2010-10-25
    相关资源
    最近更新 更多