Welcome!

Share and discuss the best content and new marketing ideas, build your professional profile and become a better marketer together.

Sign up

You need to be registered to interact with the community.
This question has been flagged
1 Reply
21 Views

Hey Cyllo peeps, anyone know how to add a new icon in systray? I need to add a new icon to do specific actions.

Avatar
Discard

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',
   ],
},

Avatar
Discard

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!