İç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 do i utilize odoo's websocket connection ?

Abone Ol

Get notified when there's activity on this post

Bu soru işaretlendi
developmentcustom
1 Cevapla
3219 Görünümler
Avatar
John Louie

Good day everyone, I'm currently building a custom module and utilizing its controllers to create an external api with custom logic for endpoints like /api/auth/login , /api/auth/whoami etc. Basically it's an attendance logging api for my custom module and is integrated to a mobile application. Currently, I was looking how to make it so that my endpoint for attendnace logging could send notifications to the mobile application. I was thinking of utilizing a websocket and odoo has it's own websocket but i'm having a hard time how to implement it. For reference, here is the endpoint where i want to integrate a notification and basically establish a websocket connection. 


 # ───────────────────────────────────────────────────────────────

    # ATTENDANCE  –  /api/attendance/log  (POST)

    # ───────────────────────────────────────────────────────────────

    @http.route(

        "/api/attendance/log", type="http", auth="public", csrf=False, methods=["POST"]

    )

    def log_attendance(self):

        user = self._current_user()

        if not user:

            return self._json({"error": "Unauthorized"}, 401)

        if user.share:

            return self._json({"error": "Access denied: internal users only"}, 403)


        try:

            data = json.loads(request.httprequest.data or "{}")

        except Exception:

            return self._json({"error": "Malformed JSON body"}, 400)


        enrollment_id = data.get("enrollment_id")

        log_type = data.get("log_type")

        if not enrollment_id or not log_type:

            return self._json({"error": "enrollment_id and log_type are required"}, 400)


        enrollment = request.env["sis.enrollment"].sudo().browse(int(enrollment_id))

        if not enrollment.exists():

            return self._json({"error": "Student does not exist"}, 404)


        try:

            log = (

                request.env["sis.student.attendance.log"]

                .sudo()

                .create(

                    {

                        "enrollment_id": enrollment.id,

                        "log_type": log_type,

                    }

                )

            )

        except ValidationError as ve:

            return self._json({"error": str(ve)}, 400)

        except Exception as e:

            _logger.exception("Failed to log attendance")

            return self._json({"error": str(e)}, 500)


        return self._json(

            {

                "status": "success",

                "log_id": log.id,

                "student_name": enrollment.full_name,

                "section_name": enrollment.section_id.display_name,

            },

            201,

        )

So basically it is an attendance logging of a student and i want to notify their parent in the mobile application once their son/daughter times in/out of their school

0
Avatar
Vazgeç
Avatar
STAFFINSIDE
En İyi Yanıt

Hi John,

Odoo’s “websocket” is really the longpolling bus that powers live chat, notifications, and Discuss. It’s not a raw websocket server you can hook into directly, but you can piggyback on it.

For your case (attendance → push update to mobile app), the usual pattern is:

  1. Use the bus.bus model

    request.env['bus.bus'].sudo().sendone( f"attendance_{enrollment_id}", { "student": enrollment.full_name, "section": enrollment.section_id.display_name, "log_type": log_type, } )

    This publishes a message on a custom channel.
  2. Subscribe from your client
    Your mobile app (or another backend service) connects to /longpolling/poll with the channel name (attendance_123). Whenever you sendone, the subscriber gets the payload.
  3. Alternative: external websocket
    If you really need true websockets, you’ll have to spin up a small websocket server (Node, FastAPI, etc.), and then trigger it from Odoo (via HTTP call, RabbitMQ, Redis, etc.) whenever a log is created.

So if you want to stay “inside” Odoo, stick to the bus/longpolling. If you want a native websocket to push directly to your mobile app, you’ll need a separate service alongside Odoo.

Hope that clears it up!

0
Avatar
Vazgeç
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
@guia@¿Cómo hablar con una persona en Air France?
development
Avatar
0
Ara 25
2
How do I change the name of the module, or rather the name assigned to the module, after I created it in Odoo Studio?
development
Avatar
Avatar
1
Ara 25
429
Feature Request: Native “Dialog Filters” in Search Panel
development
Avatar
0
Kas 25
174
Solution to the Getting Started tutorial from the official Odoo 16 documentation
development
Avatar
Avatar
Avatar
2
Kas 25
1555
Guest House Module - Rental Search Bar
development
Avatar
Avatar
1
Kas 25
258
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