Hey Cyllo peeps, anyone know how to add a new icon in systray? I need to add a new icon to do specific actions.
Welcome!
Share and discuss the best content and new marketing ideas, build your professional profile and become a better marketer together.
This question has been flagged
To set up a system tray icon in the menu bar and associate an action with it, start by creating a new directory. Inside this directory, create a folder named 'static'. Next, within the 'static' folder, establish two additional folders labeled 'JS' and 'XML'.
class="fa fa-star-o"
title="My Custom Icon"
style="cursor: pointer; font-size: 18px;"
t-on-click="showNotification"
/>
This XML code defines a system tray icon template named
"systray_icon" for Odoo using OWL, featuring a clickable star icon. When clicked, it triggers a "showNotification" function,
intended to display a notification to the user.
/** @odoo-module **/
import { registry } from "@web/core/registry";
import { useService } from "@web/core/utils/hooks";
import { Component } from "@odoo/owl";
class SystrayIcon extends Component {
setup() {
super.setup();
this.notification = useService("notification");
}
showNotification() {
this.notification.add("Hello! This is a notification", {
title: "Systray Notification",
type: "info",
sticky: false,
});
}
}
SystrayIcon.template = "systray_icon";
export const systrayItem = {
Component: SystrayIcon,
};
registry.category("systray").add("SystrayIcon", systrayItem, { sequence: 1 });
Now, we need to declare these files to the assets in the manifest file.
'assets': {
'web.assets_backend': [
'systray_menu_favourites/static/src/js/systray.js',
'systray_menu_favourites/static/src/xml/systray_templates.xml',
],
},