How to Add New Item in CogMenu in Odoo 17

CelineGeorge1 693 views 9 slides Sep 30, 2024
Slide 1
Slide 1 of 9
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9

About This Presentation

In Odoo 17, CogMenu (or Configuration Menu) is a feature typically found in various modules that allows users to configure settings related to that specific module. It has a cogwheel like icon usually located on the top left side of the screen. By default, the features for Importing and Exporting wi...


Slide Content

How to Add New Item in CogMenu in Odoo 17 Enterprise

Introduction Enterprise In Odoo 17, CogMenu (or Configuration Menu) is a feature typically found in various modules that allows users to configure settings related to that specific module. It has a cogwheel like icon usually located on the top left side of the screen. By default, the features for Importing and Exporting will be available inside the menu.

Enterprise For example, this is the CogMenu that we can see in Sales module

Enterprise To create a new custom menu inside this Cogmenu of Odoo 17, we can just create a new module which will have a structure like

Enterprise The file cog_menu.js have the javascript code /**@odoo-module **/ import { DropdownItem } from "@web/core/dropdown/dropdown_item"; import { registry } from "@web/core/registry"; const { Component } = owl; const cogMenuRegistry = registry.category("cogMenu"); export class CogMenu extends Component { async actionCustomMenu() { var currentModel = this.env.searchModel.resModel console.log(currentModel) // Include your action for the menu here... } } CogMenu.template = "cog_menu_item.NewOption"; CogMenu.components = { DropdownItem }; export const CogMenuItem = { Component: CogMenu, groupNumber: 20, isDisplayed: ({ config }) => config.viewType != "form", }; cogMenuRegistry.add("custom-menu", CogMenuItem, { sequence: 10 });

Enterprise The file cog_menu.xml have the xml code <?xml version="1.0" encoding="UTF-8"?> <templates xml:space="preserve"> <t t-name="cog_menu_item.NewOption" owl="1"> <DropdownItem class="'o_cog_menu'" onSelected.bind="actionCustomMenu"> Custom Menu </DropdownItem> </t> </templates>

Enterprise This will display the new menu item on the Cog menu as

Enterprise We have written the bind method js code for the menu to show the current model’s name on the console. So, on clicking the new menu item and inspecting the page to get the console, we can see the current module name like

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