Skip ke Konten
Odoo Menu
  • Login
  • Uji coba gratis
  • Aplikasi
    Keuangan
    • Akuntansi
    • Faktur
    • Pengeluaran
    • Spreadsheet (BI)
    • Dokumen
    • Tanda Tangan
    Sales
    • CRM
    • Sales
    • POS Toko
    • POS Restoran
    • Langganan
    • Rental
    Website
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Rantai Pasokan
    • Inventaris
    • Manufaktur
    • PLM
    • Purchase
    • Maintenance
    • Kualitas
    Sumber Daya Manusia
    • Karyawan
    • Rekrutmen
    • Cuti
    • Appraisal
    • Referensi
    • Armada
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Acara
    • Otomatisasi Marketing
    • Survei
    Layanan
    • Project
    • Timesheet
    • Layanan Lapangan
    • Meja Bantuan
    • Planning
    • Appointment
    Produktivitas
    • Diskusi
    • Approval
    • IoT
    • VoIP
    • Pengetahuan
    • WhatsApp
    Aplikasi pihak ketiga Odoo Studio Platform Odoo Cloud
  • Industri-Industri
    Retail
    • Toko Buku
    • Toko Baju
    • Toko Furnitur
    • Toko Kelontong
    • Toko Hardware
    • Toko Mainan
    Makanan & Hospitality
    • Bar dan Pub
    • Restoran
    • Fast Food
    • Rumah Tamu
    • Distributor Minuman
    • Hotel
    Real Estate
    • Agensi Real Estate
    • Firma Arsitektur
    • Konstruksi
    • Estate Management
    • Perkebunan
    • Asosiasi Pemilik Properti
    Konsultansi
    • Firma Akuntansi
    • Mitra Odoo
    • Agensi Marketing
    • Firma huku
    • Talent Acquisition
    • Audit & Sertifikasi
    Manufaktur
    • Tekstil
    • Logam
    • Perabotan
    • Makanan
    • Brewery
    • Corporate Gift
    Kesehatan & Fitness
    • Sports Club
    • Toko Kacamata
    • Fitness Center
    • Wellness Practitioners
    • Farmasi
    • Salon Rambut
    Perdagangan
    • Handyman
    • IT Hardware & Support
    • Sistem-Sistem Energi Surya
    • Pembuat Sepatu
    • Cleaning Service
    • Layanan HVAC
    Lainnya
    • Organisasi Nirlaba
    • Agen Lingkungan
    • Rental Billboard
    • Fotografi
    • Penyewaan Sepeda
    • Reseller Software
    Browse semua Industri
  • Komunitas
    Belajar
    • Tutorial-tutorial
    • Dokumentasi
    • Sertifikasi
    • Pelatihan
    • Blog
    • Podcast
    Empower Education
    • Program Edukasi
    • Game Bisnis 'Scale Up!'
    • Kunjungi Odoo
    Dapatkan Softwarenya
    • Download
    • Bandingkan Edisi
    • Daftar Rilis
    Kolaborasi
    • Github
    • Forum
    • Acara
    • Terjemahan
    • Menjadi Partner
    • Layanan untuk Partner
    • Daftarkan perusahaan Akuntansi Anda.
    Dapatkan Layanan
    • Temukan Mitra
    • Temukan Akuntan
    • Temui penasihat
    • Layanan Implementasi
    • Referensi Pelanggan
    • Bantuan
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dapatkan demo
  • Harga
  • Bantuan

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

  • CRM
  • e-Commerce
  • Akuntansi
  • Inventaris
  • PoS
  • Project
  • MRP
All apps
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Help

Update javascript owl component with a bus from python

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
javascriptpythonbusowlodoo16features
2 Replies
5495 Tampilan
Avatar
Tomeu Clar

I'm trying to create a custom module in Odoo 16.0, that adds a systray for timesheets, the idea is to have the currently active one and below it a list of the latest ones.

Here is the code of what I have for now:


timesheet_menu.js

/** @odoo-module **/

import
{Dropdown} from "@web/core/dropdown/dropdown";
import {DropdownItem} from "@web/core/dropdown/dropdown_item";
import {registry} from "@web/core/registry";

import {Component, onWillStart, useState} from "@odoo/owl";
import {useService} from "@web/core/utils/hooks";

export class TimesheetMenu extends Component {
model = "account.analytic.line";

setup() {
this.orm = useService("orm");

this.state = useState({
timesheets: [],
});

onWillStart(async () => {
await this.loadTimesheetsData();
});
}

async loadTimesheetsData() {
this.state.timesheets = await this.orm.searchRead(this.model, [["project_id", "!=", false]], ["id", "name"]);
}
}

TimesheetMenu.template = "advanced_timesheet.TimesheetMenu";
TimesheetMenu.components = {Dropdown, DropdownItem};

export const timesheetItem = {
Component: TimesheetMenu,
};

registry.category("systray").add("advanced_timesheet.timesheet_menu", timesheetItem, {sequence: 85});


timesheet_menu.xml

<?xml version="1.0" encoding="UTF-8"?>
<
templates xml:space="preserve">

<
t t-name="se7_advanced_timesheet.TimesheetMenu" owl="1">
<
Dropdown class="'d-none d-md-block'">
<
t t-set-slot="toggler">
<
i class="fa fa-play-circle"/>
<
/t>
<
t t-foreach="state.timesheets" t-as="timesheet" t-key="timesheet.id">
<
DropdownItem>
<
t t-esc="timesheet.name"/>
<
/DropdownItem>
<
/t>
<
/Dropdown>
<
/t>

<
/templates>


It works well and adds it correctly.


The problem now is that I want to use the bus so that when a timesheet is updated, it also updates the component in JavaScript.

For example, when a timesheet starts/stops is added, it is reflected in the systray.


My idea to do that was to use the bus, but I haven't found anything to receive the bus update in javascript.

In python, if I'm not mistaken, it would be done like this:

self.env['bus.bus']._sendone(channel, notification_type, message)


I think I don't quite understand how buses work, but it seems to me that it would be something like this.

Can anyone guide me in the right direction to do this, or is this not possible?


Thank you

0
Avatar
Buang
Avatar
Yoel González Díaz
Jawaban Terbai

This solution shows me the following error:
Caused by: TypeError: Cannot read properties of undefined (reading 'addChannel')

I'm in Odoo 16 comunity edition :(

0
Avatar
Buang
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Jawaban Terbai

Hi,

You should add these lines of code in the setup function of TimeSheet component

setup(){
this.busService = this.env.services.bus_service
            this.channel = “Timesheet"
            this.busService.addChannel(this.channel)
            this.busService.addEventListener("notification", this.onMessage.bind(this))
}

onMessage({ detail: notifications }) {
   //Your logic
        }


Server side

channel = "Timesheet"
        message = {
            "result": “your_data”,
            "channel": channel
        }
        self.env["bus.bus"]._sendone(channel, "notification", message)

This should indeed sent the data to the client and you can write your custom logic in the onMessage function


Hope it helps

0
Avatar
Buang
Menikmati diskusi? Jangan hanya membaca, ikuti!

Buat akun sekarang untuk menikmati fitur eksklufi dan agar terlibat dengan komunitas kami!

Daftar
Post Terkait Replies Tampilan Aktivitas
How to create javascript event on Odoo16?
javascript owl odoo16features
Avatar
Avatar
Avatar
Avatar
3
Des 23
7494
Getting a 404 error when calling a Model Function in owl JavaScript file in Odoo 16
javascript owl odoo16features
Avatar
Avatar
Avatar
2
Jul 23
4699
Error when using userService("orm") - odoo16
javascript orm owl odoo16features
Avatar
Avatar
1
Jun 24
4350
Effect Service in Owl Framework - Odoo16
javascript services owl odoo16features
Avatar
Avatar
1
Jun 24
2778
Select Customer before creating order pos odoo 16
javascript pos owl odoo16features
Avatar
0
Jan 24
2355
Komunitas
  • Tutorial-tutorial
  • Dokumentasi
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Terjemahan
Layanan
  • Odoo.sh Hosting
  • Bantuan
  • Peningkatan
  • Custom Development
  • Pendidikan
  • Temukan Akuntan
  • Temukan Mitra
  • Menjadi Partner
Tentang Kami
  • Perusahaan kami
  • Aset Merek
  • Hubungi kami
  • Tugas
  • Acara
  • Podcast
  • Blog
  • Pelanggan
  • Hukum • Privasi
  • Keamanan
الْعَرَبيّة 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 adalah rangkaian aplikasi bisnis open source yang mencakup semua kebutuhan perusahaan Anda: CRM, eCommerce, akuntansi, inventaris, point of sale, manajemen project, dan seterusnya.

Mudah digunakan dan terintegrasi penuh pada saat yang sama adalah value proposition unik Odoo.

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