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

Update javascript owl component with a bus from python

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
javascriptpythonbusowlodoo16features
2 Odpowiedzi
5460 Widoki
Awatar
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
Awatar
Odrzuć
Awatar
Yoel González Díaz
Najlepsza odpowiedź

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
Awatar
Odrzuć
Awatar
Cybrosys Techno Solutions Pvt.Ltd
Najlepsza odpowiedź

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
Awatar
Odrzuć
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 to create javascript event on Odoo16?
javascript owl odoo16features
Awatar
Awatar
Awatar
Awatar
3
gru 23
7471
Getting a 404 error when calling a Model Function in owl JavaScript file in Odoo 16
javascript owl odoo16features
Awatar
Awatar
Awatar
2
lip 23
4681
Error when using userService("orm") - odoo16
javascript orm owl odoo16features
Awatar
Awatar
1
cze 24
4306
Effect Service in Owl Framework - Odoo16
javascript services owl odoo16features
Awatar
Awatar
1
cze 24
2750
Select Customer before creating order pos odoo 16
javascript pos owl odoo16features
Awatar
0
sty 24
2340
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