İçereği Atla
Odoo Menü
  • Portal
  • Ücretsiz deneyin
  • Uygulamalar
    Finans
    • Muhasebe
    • Faturalama
    • Masraf Yönetimi
    • Elektronik Çizelge (BI)
    • Belgeler
    • İmza
    Satış
    • Müşteri İlişkileri Yönetimi (CRM)
    • Satış
    • Satış Noktası Mağaza
    • Satış Noktası Restoran
    • Abonelikler
    • Kiralama
    Web Sitesi
    • Web Sitesi Oluşturucu
    • eTicaret
    • Blog
    • Forum
    • Canlı Sohbet
    • eÖğrenme
    Tedarik Zinciri
    • Envanter
    • Üretim
    • Ürün Yaşam Döngüsü Yönetimi
    • Satın Alma
    • Bakım
    • Kalite
    İnsan Kaynakları
    • Çalışanlar
    • İşe Alım
    • İzin
    • Değerlendirme
    • Referans
    • Filo Yönetimi
    Pazarlama
    • Sosyal Medyada Pazarlama
    • E-posta ile Pazarlama
    • SMS ile Pazarlama
    • Etkinlikler
    • Pazarlama Otomasyonu
    • Anket
    Hizmetler
    • Proje Yönetimi
    • Çalışma Çizelgeleri
    • Saha Hizmeti
    • Yardım Masası
    • Planlama
    • Randevular
    Verimlilik
    • Sohbet
    • Onay
    • Nesnelerin İnterneti
    • VoIP
    • Bilgi Bankası
    • WhatsApp
    Üçüncü taraf uygulamalar Odoo Stüdyo Odoo Bulut Platformu
  • Sektörler
    Perakende satış
    • Kitapçı
    • Giyim Mağazası
    • Mobilya Mağazası
    • Gıda Marketi
    • Hırdavat Dükkanı
    • Oyuncak Dükkanı
    Gıda ve Konaklama
    • Bar ve Pub
    • Restoran
    • Fast Food Restoranı
    • Konuk Evi
    • İçecek Distribütörü
    • Otel
    Gayrimenkul
    • Emlak Acentesi
    • Mimarlık Firması
    • İnşaat
    • Emlak Yönetimi
    • Bahçe Tasarımı
    • Mülk Sahipleri Derneği
    Uzmanlık
    • Muhasebe Firması
    • Odoo Partner
    • Pazarlama Ajansı
    • Hukuk Firması
    • Yetenek Kazanımı
    • Denetim ve Belgelendirme
    Üretim
    • Tekstil
    • Metal
    • Mobilyalar
    • Gıda
    • Bira fabrikası
    • Kurumsal Hediye
    Sağlık ve Spor
    • Spor Kulübü
    • Optik Mağazası
    • Fitness Merkezi
    • Sağlıklı Yaşam Merkezi
    • Eczane
    • Kuaför Salonu
    Ticaret
    • Tamirci
    • BT Donanım & Destek
    • Güneş Enerjisi Sistemleri
    • Ayakkabı İmalatçısı
    • Temizlik Hizmetleri
    • HVAC Hizmetleri
    Diğerleri
    • Kar Amacı Gütmeyen Kuruluş
    • Çevre Ajansı
    • Reklam Panosu Kiralama
    • Fotoğrafçılık
    • Bisiklet Kiralama
    • Yazılım Bayisi
    Tüm Sektörlere Göz Atın
  • Topluluk
    Öğrenim
    • Eğitim Araçları
    • Dokümantasyon
    • Sertifikasyonlar
    • Eğitim Etkinlikleri
    • Blog
    • Podcast
    Eğitim ve Gelişim
    • Eğitim Programı
    • Scale Up! İşletme Oyunu
    • Odoo'yu Ziyaret Edin
    Yazılım
    • İndirin
    • Sürümleri Kıyaslayın
    • Sürümler
    İş Birliği
    • Github
    • Forum
    • Etkinlikler
    • Çeviriler
    • Partner Olun
    • Partnerler için Hizmetler
    • Muhasebe Firmanızı Kaydettirin
    Hizmetler
    • Partner Bulun
    • Muhasebeci Bulun
    • Bir danışmanla görüşün
    • Kurulum Hizmetleri
    • Müşteri Referansları
    • Destek
    • Sürüm Yükseltme
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Demo randevusu alın
  • Fiyatlandırma
  • Yardım

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

  • Müşteri İlişkileri Yönetimi
  • e-Commerce
  • Muhasebe
  • Envanter
  • PoS
  • Proje Yönetimi
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiketler (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiketler (View all)
odoo accounting v14 pos v15
About this forum
Yardım

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

Abone Ol

Get notified when there's activity on this post

Bu soru işaretlendi
javascriptmethodoverride
3 Cevaplar
7423 Görünümler
Avatar
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
Avatar
Vazgeç
Avatar
Pascal Tremblay
Üretici En İyi Yanıt

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
Avatar
Vazgeç
Avatar
Shameem Babu
En İyi Yanıt

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
Avatar
Vazgeç
Pascal Tremblay
Üretici

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.

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Üye Ol
İlgili Gönderiler Cevaplar Görünümler Aktivite
How i can override the activity js file in odoo 14?
javascript override
Avatar
Avatar
1
Ağu 23
3789
Override JS mail Çözüldü
javascript override
Avatar
Avatar
Avatar
3
Tem 21
5983
inheriting Javascript file Odoo 12
javascript override
Avatar
Avatar
1
Ağu 19
4184
override the makeOrder method.
method override
Avatar
0
May 16
4062
override a method inheritance Çözüldü
method override
Avatar
Avatar
Avatar
2
Ara 15
3482
Topluluk
  • Eğitim Araçları
  • Dokümantasyon
  • Forum
Açık Kaynak
  • İndirin
  • Github
  • Runbot
  • Çeviriler
Hizmetler
  • Odoo.sh Hosting
  • Destek
  • Sürüm Yükseltme
  • Özel Geliştirmeler
  • Eğitim
  • Muhasebeci Bulun
  • Partner Bulun
  • Partner Olun
Hakkında
  • Şirketimiz
  • Pazarlama Gereçleri
  • İletişim
  • Kariyer
  • Etkinlikler
  • Podcast
  • Blog
  • Müşteriler
  • Hukuki • Gizlilik
  • Güvenlik
الْعَرَبيّة 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, müşteri ilişkileri yönetimi, eTicaret, muhasebe, envanter, satış noktası, proje yönetimi gibi şirketinizin tüm ihtiyaçlarını karşılayan bir açık kaynak işletme uygulamaları paketidir.

Odoo’nun eşsiz değer önermesi, aynı anda hem kullanımının çok kolay olup hem de tamamen entegre olmasıdır.

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