SlideShare a Scribd company logo
2
Most read
5
Most read
9
Most read
How to make a component
and add it to systray in Odoo
Enterprise
Introduction
Enterprise
The system tray icon in Odoo serves as a quick-access feature, allowing
users to easily interact with certain functionalities of the Odoo system
without navigating through the main interface.
It is located in the notification bar. The icons in the menu may vary
according to the modules installed. The marked area indicates the systray
icons
Enterprise
Let’s check how can we make a new icon to show on the systray
menu and add action to it. We can create a module directory for it.
The structure will be as follows
Enterprise
Inside the manifest, register the js and xml files as
'assets': {
'web.assets_backend': [
'systray_icon/static/src/js/systray_icon.js',
'systray_icon/static/src/xml/systray_icon.xml',
]
}
Enterprise
The file systray_icon.xml contains the xml code for showing our
custom icon in the view.
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">
<t t-name="systray_icon" owl="1">
<Dropdown>
<t t-set-slot="toggler">
<div class="new_icon">
<div class="icon_div">
<div class="toggle-icon" role="button">
<i id='create_order' class="fa fa-shopping-cart fa-1.5x"
role="img" aria-label="Sale/Purchase Order"/>
</div></div></div></t>
<t t-set-slot="default">
<DropdownItem><div t-on-click="_openSaleModel"> Sale Order </div></DropdownItem>
<DropdownItem><div t-on-click="_openPurchaseModel">Purchase Order</div></DropdownItem>
</t>
</Dropdown>
</t>
</templates>
Enterprise
This will make a new ‘shopping cart’ icon to be visible on the systray
which will then give a dropdown menu containing two buttons as
Sale Order and Purchase Order when clicked.
Enterprise
Now we need to define the Actions for the two buttons we added.
Let’s add a simple logic to open a form view to create new Sale
order or Purchase Order for the respective buttons. For that, we
type the code in js under static/src/js directory of the module.
The very step is to add the line /** @odoo-module **/ and to
import the registry, useService, Owl component, Dropdown and
Dropdown Item.
/** @odoo-module **/
import { registry } from "@web/core/registry";
import { useService } from "@web/core/utils/hooks";
import { Component } from "@odoo/owl";
import {Dropdown} from '@web/core/dropdown/dropdown';
import {DropdownItem} from '@web/core/dropdown/dropdown_item';
Enterprise
From the javascript code in Odoo, the classes are extended using
extend keyword. This is used to create a new class or component
from an existing class by inheriting all its properties and methods of
the parent class. New methods can be defined or existing ones can
be overridden or added with new functionalities.
Here we create the new class SystrayIcon from the existing class
Component as
class SystrayIcon extends Component
Enterprise
Along with the setup(), we need to define the two onclick methods
_openSaleModel and _openPurchaseModel we mentioned in the
xml file. Both of them will open the form views of sale.order and
purchase.order respectively.
And for these click events, we use this.action.doAction() method to
open a window action and pass the details such as type, name,
res_model, view_mode, etc about the view we need to open.
Enterprise
class SystrayIcon extends Component {
setup() {
super.setup(...arguments);
this.action = useService("action");
}
_openSaleModel() {
this.action.doAction({
type: "ir.actions.act_window",
name: "Sale Order",
res_model: "sale.order",
view_mode: "form",
views: [[false, "form"]],
target: "new",
});
}
_openPurchaseModel(){
this.action.doAction({
type: "ir.actions.act_window",
name: "Purchase Order",
res_model: "purchase.order",
view_mode: "form",
views: [[false, "form"]],
target: "new",
});
}
}
Enterprise
Now, give the template for the new class with the same template
name we created in xml. And register the component and
systrayItem as
SystrayIcon.template = "systray_icon";
SystrayIcon.components = {Dropdown, DropdownItem };
export const systrayItem = { Component: SystrayIcon,};
registry.category("systray").add("SystrayIcon", systrayItem, { sequence: 1 });
Enterprise
Now on clicking the first button ‘Sale Order’ from the shopping cart
systray icon, we get
Enterprise
Likewise, for the ‘Purchase Order’ button click, we get
For More Info.
Check our company website for related blogs
and Odoo book.
Check our YouTube channel for
functional and technical videos in Odoo.
Enterprise
www.cybrosys.com

More Related Content

PPTX
Tips On Trick Odoo Add-On.pptx
PPTX
How To Extend Odoo Form View using js_class_
PPTX
Client Actions In Odoo 17 - Odoo 17 Slides
PPTX
How to Create and Manage Wizard in Odoo 17
ODT
Eclipse Tricks
PPT
Backbone.js
PPTX
How to Load JS Function in Menu Item Click in Odoo 17
PPTX
How to use Init Hooks in Odoo 18 - Odoo Slides
Tips On Trick Odoo Add-On.pptx
How To Extend Odoo Form View using js_class_
Client Actions In Odoo 17 - Odoo 17 Slides
How to Create and Manage Wizard in Odoo 17
Eclipse Tricks
Backbone.js
How to Load JS Function in Menu Item Click in Odoo 17
How to use Init Hooks in Odoo 18 - Odoo Slides

Similar to How to make a component and add it to systray in Odoo (20)

DOCX
ASP.NET MVC3 RAD
PPTX
Yii in action
PDF
ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010
PPTX
Different types of inheritance in odoo 18
PDF
Advance RCP
PPS
Actionview
DOC
Cis407 a ilab 6 web application development devry university
DOCX
Repository Pattern in MVC3 Application with Entity Framework
PPTX
How to add Many2Many fields in odoo website form.pptx
DOCX
Cis 407 i lab 6 of 7
PPTX
How Owl.js Masterfully Blends React and Vue Awesomeness in odoo
PPTX
URLs and Routing in the Odoo 17 Website App
PPTX
Sencha ExtJs Learning Part 2 - MVC And MVVM Architecture in ExtJs [ENGLISH]
PDF
Understanding router state in angular 7 passing data through angular router s...
PPTX
Tips On Trick Odoo Add-On.pptx
DOCX
need help completing week 6 ilab.. i will upload what I currently ha.docx
PPTX
How to Create a Dynamic Snippet in Odoo 17
PDF
Whmcs addon module docs
PPTX
Uninstall Hook in Odoo 17 - Odoo 17 Slides
PPT
DJango
ASP.NET MVC3 RAD
Yii in action
ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010
Different types of inheritance in odoo 18
Advance RCP
Actionview
Cis407 a ilab 6 web application development devry university
Repository Pattern in MVC3 Application with Entity Framework
How to add Many2Many fields in odoo website form.pptx
Cis 407 i lab 6 of 7
How Owl.js Masterfully Blends React and Vue Awesomeness in odoo
URLs and Routing in the Odoo 17 Website App
Sencha ExtJs Learning Part 2 - MVC And MVVM Architecture in ExtJs [ENGLISH]
Understanding router state in angular 7 passing data through angular router s...
Tips On Trick Odoo Add-On.pptx
need help completing week 6 ilab.. i will upload what I currently ha.docx
How to Create a Dynamic Snippet in Odoo 17
Whmcs addon module docs
Uninstall Hook in Odoo 17 - Odoo 17 Slides
DJango
Ad

More from Celine George (20)

PPTX
How to Implement OWL Notification Service in Odoo 18
PPTX
Tracking Profit Margins in Sales Orders with Odoo 18
PPTX
How to Configure Outgoing Shipment in 3 Steps Using Odoo 18
PPTX
How to Configure Outgoing Shipment in 1 Step Using Odoo 18.pptx
PPTX
How to Configure Outgoing Shipment in 2 Steps Using Odoo 18
PPTX
How to Add New Applicants in Odoo 18 Recruitment
PPTX
How to Analyze the Recruitment Process in Odoo 18 Recruitment
PPTX
How to Manage Referral Reporting in Odoo 18 Referrals
PPTX
How to Set, Track, & Review Employee Goals in Odoo 18 Appraisals
PPTX
Revamp in MTO Odoo 18 Inventory - Odoo Slides
PPTX
How to Manage Starshipit in Odoo 18 - Odoo Slides
PPTX
How to Manage Bill Control Policy in Odoo 18
PPTX
How to Manage Loyalty Points in Odoo 18 Sales
PPTX
Odoo 18 Sales_ Managing Quotation Validity
PPTX
How to Manage Global Discount in Odoo 18 POS
PPTX
How to Manage Leads in Odoo 18 CRM - Odoo Slides
PPTX
Tips Management in Odoo 18 POS - Odoo Slides
PPTX
How to Close Subscription in Odoo 18 - Odoo Slides
PPTX
Kanban Cards _ Mass Action in Odoo 18.2 - Odoo Slides
PPTX
How to Track Skills & Contracts Using Odoo 18 Employee
How to Implement OWL Notification Service in Odoo 18
Tracking Profit Margins in Sales Orders with Odoo 18
How to Configure Outgoing Shipment in 3 Steps Using Odoo 18
How to Configure Outgoing Shipment in 1 Step Using Odoo 18.pptx
How to Configure Outgoing Shipment in 2 Steps Using Odoo 18
How to Add New Applicants in Odoo 18 Recruitment
How to Analyze the Recruitment Process in Odoo 18 Recruitment
How to Manage Referral Reporting in Odoo 18 Referrals
How to Set, Track, & Review Employee Goals in Odoo 18 Appraisals
Revamp in MTO Odoo 18 Inventory - Odoo Slides
How to Manage Starshipit in Odoo 18 - Odoo Slides
How to Manage Bill Control Policy in Odoo 18
How to Manage Loyalty Points in Odoo 18 Sales
Odoo 18 Sales_ Managing Quotation Validity
How to Manage Global Discount in Odoo 18 POS
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Tips Management in Odoo 18 POS - Odoo Slides
How to Close Subscription in Odoo 18 - Odoo Slides
Kanban Cards _ Mass Action in Odoo 18.2 - Odoo Slides
How to Track Skills & Contracts Using Odoo 18 Employee
Ad

Recently uploaded (20)

PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
01-Introduction-to-Information-Management.pdf
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
RMMM.pdf make it easy to upload and study
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
Basic Mud Logging Guide for educational purpose
PDF
Classroom Observation Tools for Teachers
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
Institutional Correction lecture only . . .
PPTX
PPH.pptx obstetrics and gynecology in nursing
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Microbial diseases, their pathogenesis and prophylaxis
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
01-Introduction-to-Information-Management.pdf
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
RMMM.pdf make it easy to upload and study
STATICS OF THE RIGID BODIES Hibbelers.pdf
O7-L3 Supply Chain Operations - ICLT Program
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Basic Mud Logging Guide for educational purpose
Classroom Observation Tools for Teachers
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
O5-L3 Freight Transport Ops (International) V1.pdf
Abdominal Access Techniques with Prof. Dr. R K Mishra
Institutional Correction lecture only . . .
PPH.pptx obstetrics and gynecology in nursing
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...

How to make a component and add it to systray in Odoo

  • 1. How to make a component and add it to systray in Odoo Enterprise
  • 2. Introduction Enterprise The system tray icon in Odoo serves as a quick-access feature, allowing users to easily interact with certain functionalities of the Odoo system without navigating through the main interface. It is located in the notification bar. The icons in the menu may vary according to the modules installed. The marked area indicates the systray icons
  • 3. Enterprise Let’s check how can we make a new icon to show on the systray menu and add action to it. We can create a module directory for it. The structure will be as follows
  • 4. Enterprise Inside the manifest, register the js and xml files as 'assets': { 'web.assets_backend': [ 'systray_icon/static/src/js/systray_icon.js', 'systray_icon/static/src/xml/systray_icon.xml', ] }
  • 5. Enterprise The file systray_icon.xml contains the xml code for showing our custom icon in the view. <?xml version="1.0" encoding="UTF-8" ?> <templates xml:space="preserve"> <t t-name="systray_icon" owl="1"> <Dropdown> <t t-set-slot="toggler"> <div class="new_icon"> <div class="icon_div"> <div class="toggle-icon" role="button"> <i id='create_order' class="fa fa-shopping-cart fa-1.5x" role="img" aria-label="Sale/Purchase Order"/> </div></div></div></t> <t t-set-slot="default"> <DropdownItem><div t-on-click="_openSaleModel"> Sale Order </div></DropdownItem> <DropdownItem><div t-on-click="_openPurchaseModel">Purchase Order</div></DropdownItem> </t> </Dropdown> </t> </templates>
  • 6. Enterprise This will make a new ‘shopping cart’ icon to be visible on the systray which will then give a dropdown menu containing two buttons as Sale Order and Purchase Order when clicked.
  • 7. Enterprise Now we need to define the Actions for the two buttons we added. Let’s add a simple logic to open a form view to create new Sale order or Purchase Order for the respective buttons. For that, we type the code in js under static/src/js directory of the module. The very step is to add the line /** @odoo-module **/ and to import the registry, useService, Owl component, Dropdown and Dropdown Item. /** @odoo-module **/ import { registry } from "@web/core/registry"; import { useService } from "@web/core/utils/hooks"; import { Component } from "@odoo/owl"; import {Dropdown} from '@web/core/dropdown/dropdown'; import {DropdownItem} from '@web/core/dropdown/dropdown_item';
  • 8. Enterprise From the javascript code in Odoo, the classes are extended using extend keyword. This is used to create a new class or component from an existing class by inheriting all its properties and methods of the parent class. New methods can be defined or existing ones can be overridden or added with new functionalities. Here we create the new class SystrayIcon from the existing class Component as class SystrayIcon extends Component
  • 9. Enterprise Along with the setup(), we need to define the two onclick methods _openSaleModel and _openPurchaseModel we mentioned in the xml file. Both of them will open the form views of sale.order and purchase.order respectively. And for these click events, we use this.action.doAction() method to open a window action and pass the details such as type, name, res_model, view_mode, etc about the view we need to open.
  • 10. Enterprise class SystrayIcon extends Component { setup() { super.setup(...arguments); this.action = useService("action"); } _openSaleModel() { this.action.doAction({ type: "ir.actions.act_window", name: "Sale Order", res_model: "sale.order", view_mode: "form", views: [[false, "form"]], target: "new", }); } _openPurchaseModel(){ this.action.doAction({ type: "ir.actions.act_window", name: "Purchase Order", res_model: "purchase.order", view_mode: "form", views: [[false, "form"]], target: "new", }); } }
  • 11. Enterprise Now, give the template for the new class with the same template name we created in xml. And register the component and systrayItem as SystrayIcon.template = "systray_icon"; SystrayIcon.components = {Dropdown, DropdownItem }; export const systrayItem = { Component: SystrayIcon,}; registry.category("systray").add("SystrayIcon", systrayItem, { sequence: 1 });
  • 12. Enterprise Now on clicking the first button ‘Sale Order’ from the shopping cart systray icon, we get
  • 13. Enterprise Likewise, for the ‘Purchase Order’ button click, we get
  • 14. For More Info. Check our company website for related blogs and Odoo book. Check our YouTube channel for functional and technical videos in Odoo. Enterprise www.cybrosys.com