Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How to have a beep with im_chat even if the window already has the focus?

By
Pascal Tremblay
on 11/9/16, 4:10 PM 141 views

Hello there,

I note that im_chat send a beep (sound) only when the window doesn't have the focus. 

If my Odoo window already has the focus, I receive the message in the chat window, but no sound.

I'm pretty sure that I have to modify something in the im_chat.js file... But what?

I want to receive a beep even if my Odoo window has the focus.

I have to change of tab in my browser to receive a beep... Don't like it.

we are on Odoo 8.

Thanks to help


0

Pascal Tremblay

--Pascal Tremblay--
1312
| 5 2 7
Alma, Canada
--Pascal Tremblay--


Pascal Tremblay
On 11/10/16, 8:28 AM

I have overrided the receive_message function in a custom module. Now, we receive a sound notification even if the Odoo backend window has the focus in our browser.


override.xml

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <template id="override_im_chat" name="" inherit_id="web.assets_backend">
            <xpath expr="." position="inside">
                <script type="text/javascript" src="/im_chat_lapagept/static/src/js/override.js"></script>
            </xpath>
        </template>
    </data>
</openerp>


override.js

openerp.im_chat_lapagept = function(instance) {
    instance.im_chat.ConversationManager.include({               
        received_message: function(message) {
            var self = this;
            var session_id = message.to_id[0];
            var uuid = message.to_id[1];
            //THis code has been commented by PT
            //if (! this.get("window_focus")) {
                //alert('gjhgjhg');
                this.set("waiting_messages", this.get("waiting_messages") + 1);
            //}
            var conv = this.sessions[uuid];
            if(!conv){
                // fetch the session, and init it with the message
                var def_session = new openerp.Model("im_chat.session").call("session_info", [], {"ids" : [session_id]}).then(function(session){
                    conv = self.activate_session(session, false);
                    conv.received_message(message);
                });
            }else{
                conv.received_message(message);
            }
        },
      })
}

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

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

Question tools

1 follower(s)

Stats

Asked: 11/9/16, 4:10 PM
Seen: 141 times
Last updated: 11/10/16, 8:28 AM