KEMBAR78
How to Add New Item in CogMenu in Odoo 17 | PPTX
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

How to Add New Item in CogMenu in Odoo 17

  • 1.
    How to AddNew Item in CogMenu in Odoo 17 Enterprise
  • 2.
    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.
  • 3.
    Enterprise For example, thisis the CogMenu that we can see in Sales module
  • 4.
    Enterprise To create anew custom menu inside this Cogmenu of Odoo 17, we can just create a new module which will have a structure like
  • 5.
    Enterprise The file cog_menu.jshave 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 });
  • 6.
    Enterprise The file cog_menu.xmlhave 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>
  • 7.
    Enterprise This will displaythe new menu item on the Cog menu as
  • 8.
    Enterprise We have writtenthe 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
  • 9.
    For More Info. Checkour company website for related blogs and Odoo book. Check our YouTube channel for functional and technical videos in Odoo. Enterprise www.cybrosys.com