Skip to Content
Odoo Menu
  • Zaloguj się
  • Wypróbuj za darmo
  • Aplikacje
    Finanse
    • Księgowość
    • Fakturowanie
    • Wydatki
    • Arkusz kalkulacyjny (BI)
    • Dokumenty
    • Podpisy
    Sprzedaż
    • CRM
    • Sprzedaż
    • PoS Sklep
    • PoS Restauracja
    • Subskrypcje
    • Wypożyczalnia
    Strony Internetowe
    • Kreator Stron Internetowych
    • eCommerce
    • Blog
    • Forum
    • Czat na Żywo
    • eLearning
    Łańcuch dostaw
    • Magazyn
    • Produkcja
    • PLM
    • Zakupy
    • Konserwacja
    • Jakość
    Zasoby Ludzkie
    • Pracownicy
    • Rekrutacja
    • Urlopy
    • Ocena pracy
    • Polecenia Pracownicze
    • Flota
    Marketing
    • Marketing Społecznościowy
    • E-mail Marketing
    • SMS Marketing
    • Wydarzenia
    • Automatyzacja Marketingu
    • Ankiety
    Usługi
    • Projekt
    • Ewidencja czasu pracy
    • Usługi Terenowe
    • Helpdesk
    • Planowanie
    • Spotkania
    Produktywność
    • Dyskusje
    • Zatwierdzenia
    • IoT
    • VoIP
    • Baza wiedzy
    • WhatsApp
    Aplikacje trzecich stron Studio Odoo Odoo Cloud Platform
  • Branże
    Sprzedaż detaliczna
    • Księgarnia
    • Sklep odzieżowy
    • Sklep meblowy
    • Sklep spożywczy
    • Sklep z narzędziami
    • Sklep z zabawkami
    Żywienie i hotelarstwo
    • Bar i Pub
    • Restauracja
    • Fast Food
    • Pensjonat
    • Dystrybutor napojów
    • Hotel
    Agencja nieruchomości
    • Agencja nieruchomości
    • Biuro architektoniczne
    • Budowa
    • Zarządzanie nieruchomościami
    • Ogrodnictwo
    • Stowarzyszenie właścicieli nieruchomości
    Doradztwo
    • Biuro księgowe
    • Partner Odoo
    • Agencja marketingowa
    • Kancelaria prawna
    • Agencja rekrutacyjna
    • Audyt i certyfikacja
    Produkcja
    • Tekstylia
    • Metal
    • Meble
    • Jedzenie
    • Browar
    • Prezenty firmowe
    Zdrowie & Fitness
    • Klub sportowy
    • Salon optyczny
    • Centrum fitness
    • Praktycy Wellness
    • Apteka
    • Salon fryzjerski
    Transakcje
    • Złota rączka
    • Wsparcie Sprzętu IT
    • Systemy energii słonecznej
    • Szewc
    • Firma sprzątająca
    • Usługi HVAC
    Inne
    • Organizacja non-profit
    • Agencja Środowiskowa
    • Wynajem billboardów
    • Fotografia
    • Leasing rowerów
    • Sprzedawca oprogramowania
    Przeglądaj wszystkie branże
  • Community
    Ucz się
    • Samouczki
    • Dokumentacja
    • Certyfikacje
    • Szkolenie
    • Blog
    • Podcast
    Pomóż w nauce innym
    • Program Edukacyjny
    • Scale Up! Gra biznesowa
    • Odwiedź Odoo
    Skorzystaj z oprogramowania
    • Pobierz
    • Porównaj edycje
    • Wydania
    Współpracuj
    • Github
    • Forum
    • Wydarzenia
    • Tłumaczenia
    • Zostań partnerem
    • Usługi dla partnerów
    • Zarejestruj swoją firmę rachunkową
    Skorzystaj z usług
    • Znajdź partnera
    • Znajdź księgowego
    • Spotkaj się z doradcą
    • Usługi wdrożenia
    • Opinie klientów
    • Wsparcie
    • Aktualizacje
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Zaplanuj demo
  • Cennik
  • Pomoc

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Księgowość
  • Zapasy
  • PoS
  • Projekt
  • MRP
All apps
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Pomoc

How to use our new javascript method in an already overriden method?

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
javascriptmethodoverride
3 Odpowiedzi
7427 Widoki
Awatar
Pascal Tremblay

Hello there,

We have made an override of the received_message javascript method of the im_chat module.


/home/odoo-iv/addons_pt/im_chat_lapagept/override.xml

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <template id="override_im_chat_backend" 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>
        <template id="override_im_chat_frontend" inherit_id="website.assets_frontend" name="">
            <xpath expr="." position="inside">
                <script type="text/javascript" src="/im_chat_lapagept/static/src/js/override.js"></script>
            </xpath>
        </template>
    </data>
</openerp>


/home/odoo-iv/addons_pt/im_chat_lapagept/static/src/js/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 us
            //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);
            }
        },
    })
  }


This new code works well in the backend. But not on the frontend.


On the frontend, it seems that the original received_message method is still used.

We think that the problem is in the im_livechat.js file where the original received_message method is also overriden.


/home/odoo-iv/odoo-8.0-20161109/openerp/addons/im_livechat/static/src/js/im_livechat.js

    openerp.im_chat.ConversationManager.include({
        received_message: function(message) {
            try{
                this._super(message);
            }catch(e){}
        }
    });


So our question is : how could we use our new method also in im_livechat.js???

0
Awatar
Odrzuć
Awatar
Pascal Tremblay
Autor Najlepsza odpowiedź

Thanks for your comments.

Here is how we managed to do it.


In/home/odoo-iv/addons_pt/im_chat_lapagept/override.xml

<template id="override_im_livechat" inherit_id="im_livechat.internal_lib" name="">
            <xpath expr="//script[@src='/im_livechat/static/src/js/im_livechat.js']" position="after">
                <script type="text/javascript" src="/im_chat_lapagept/static/src/js/im_livechat_override.js"></script>
            </xpath>
        </template>


In/home/odoo-iv/addons_pt/im_chat_lapagept/static/src/js/im_livechat_override.js

(function() {
    "use strict";
    var _t = openerp._t;
    var im_chat_lapagept = {};
    openerp.im_chat_lapagept = im_chat_lapagept;
       
    // To avoid exeption when the anonymous has close his
    // conversation and when operator send him a message.
    openerp.im_chat.ConversationManager.include({
        received_message: function(message) {
            try{
                //alert('received_message dans im_livechat_override.js');
                var self = this;
                var session_id = message.to_id[0];
                var uuid = message.to_id[1];
                //Commented by us to have a sound notification even if the window doesn't have the focus.
                //if (! this.get("window_focus")) {
                    //alert('emettre le son livechat-js');
                    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);
                }
            }catch(e){}
        }
    });
})();


0
Awatar
Odrzuć
Awatar
Shameem Babu
Najlepsza odpowiedź

Pascal,

I faced the same issue and I solved by overriding the template of assets.

Copy both template and set id to module_name.template_name then comment the js link of that (Blocking that Js). 

<template id="im_chat_lapagept.override_im_chat_backend" 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>


<template id="im_chat_lapagept.override_im_chat_frontend" inherit_id="website.assets_frontend" name="">
    <xpath expr="." position="inside">

        <!--<script type="text/javascript" src="/im_chat_lapagept/static/src/js/override.js"></script>
        -->
    </xpath>
</template>

 Copy all contents of override.js (ctrl+A , ctrl+C) to im_livechat.js(ctrl+V).
It may override the complete override.js.

All the best !

1
Awatar
Odrzuć
Pascal Tremblay
Autor

im_livechat.js is a file in the official distribution of odoo. SHould I not put my code in a custom module rather? Thanks for your help.

Podoba Ci się ta dyskusja? Dołącz do niej!

Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!

Zarejestruj się
Powiązane posty Odpowiedzi Widoki Czynność
How i can override the activity js file in odoo 14?
javascript override
Awatar
Awatar
1
sie 23
3790
Override JS mail Rozwiązane
javascript override
Awatar
Awatar
Awatar
3
lip 21
5983
inheriting Javascript file Odoo 12
javascript override
Awatar
Awatar
1
sie 19
4188
override the makeOrder method.
method override
Awatar
0
maj 16
4062
override a method inheritance Rozwiązane
method override
Awatar
Awatar
Awatar
2
gru 15
3482
Społeczność
  • Samouczki
  • Dokumentacja
  • Forum
Open Source
  • Pobierz
  • Github
  • Runbot
  • Tłumaczenia
Usługi
  • Hosting Odoo.sh
  • Wsparcie
  • Aktualizacja
  • Indywidualne rozwiązania
  • Edukacja
  • Znajdź księgowego
  • Znajdź partnera
  • Zostań partnerem
O nas
  • Nasza firma
  • Zasoby marki
  • Skontaktuj się z nami
  • Oferty pracy
  • Wydarzenia
  • Podcast
  • Blog
  • Klienci
  • Informacje prawne • Prywatność
  • Bezpieczeństwo Odoo
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo to pakiet aplikacji biznesowych typu open source, które zaspokoją wszystkie potrzeby Twojej firmy: CRM, eCommerce, księgowość, inwentaryzacja, punkt sprzedaży, zarządzanie projektami itp.

Unikalną wartością Odoo jest to, że jest jednocześnie bardzo łatwe w użyciu i w pełni zintegrowane.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now