Odoo Help

0
0
Alejandro Santana
On 2/11/15, 12:36 PM

The only way I have found so far (remember I am completely new to JS and could not get rid of its uncontrollable asynchronous behaviour) is to override the original im_chat.js file with the one in my module. How? Using this my_module/views/im_chat.xml file:

<?xml version="1.0" encoding="utf-8"?>

<openerp>
    <data>
        <template id="im_chat.assets_backend" name="im_chat assets" inherit_id="web.assets_backend">
            <xpath expr="." position="inside">
                <link rel="stylesheet" href="/im_chat/static/src/css/im_common.css"/>
                <link rel="stylesheet" href="/im_chat/static/src/css/im_chat.css"/>
                <script type="text/javascript" src="/my_module/static/src/js/im_chat.js"></script>
            </xpath>
        </template>
    </data>
</openerp>

And in /my_module/static/src/js/im_chat.js, I had to duplicate the whole code in /im_chat/static/src/js/im_chat.js but changing some lines almost at the end. Not pretty but it works. Final if condition, modified:


    if(openerp.web && openerp.web.UserMenu) {
        openerp.web.UserMenu.include({
            do_update: function(){
                var self = this;
                var Users = new openerp.web.Model('res.users');
                var im = new openerp.im_chat.InstantMessaging(self);
                Users.call('has_group', ['base.group_user']).done(function(is_employee) {
                    if (is_employee) {
                        self.update_promise.then(function() {
                            openerp.im_chat.single = im;
                            im.appendTo(openerp.client.$el);
                            console.log("Creating im_chat for users");
                        });
                    }
                });
                Users.call('has_group', ['my_module.group_my_modulemanager']).done(function(is_employee) {
                    if (is_employee) {
                        self.update_promise.then(function() {
                            openerp.im_chat.single = im;
                            im.appendTo(openerp.client.$el);
                            var button = new openerp.im_chat.ImTopButton(this);
                            button.on("clicked", im, im.switch_display);
                            button.appendTo(window.$('.oe_systray'));
                            console.log("Creating im_chat button for managers");
                        });
                    }
                });
                return this._super.apply(this, arguments);
            },
        });
    }

 

 

 

0
Shawn Varghese
On 2/5/15, 4:55 AM

I dont have a resolution, but I may be able to give some idea as to why this happens.

I think the problem is that you are returning the super method:

return this._super.apply(this, arguments);

As I understand it, 'super' calls the parent method, which in this case is the original function. Therefore, your function as well as the original function gets invoked. If you comment that return statement, you will find that only your custom button appears and the default button does not. At least, that's what I observed in my case. But obviously, that is not the way to go. The only thing that I have been able to do in such cases is to create a copy of the whole im_chat module, make all the modifications in the copy and only install that and not the original module.

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 2/4/15, 2:20 PM
Seen: 8414 times
Last updated: 3/16/15, 8:10 AM