KEMBAR78
How to Define Menu & Actions in Odoo 18 - Odoo 18 Slides | PPTX
How to Define Menu & Actions in Odoo 18
Enterprise
Enterprise
In this slide, we will walk you through the process of defining menus
and actions in Odoo 18, offering a step-by-step look at how to
implement them with the necessary code.
Introduction
Enterprise
Setting Up the Model
Before working on menus and actions, we need to establish a foundational
model. This model will serve as the basis for menu and action
configurations. For this example, we will create a simple model to manage
student information.
Enterprise
from odoo import models, fields
class StudentData(models.Model):
_name = "student.data"
name = fields.Char(string="Name")
class_name = fields.Char(string="Class")
address = fields.Char(string="Address")
Enterprise
● _name: Defines the internal model name used in Odoo.
● name: A field to store the student's name.
● class_name: A field for the class the student belongs to.
● address: A field to hold the student's address.
This model will store basic student information, which we will later
reference in our menus and actions.
Enterprise
Defining Actions
Actions in Odoo define how users interact with data. They specify the views
(list, form, etc.) and dictate what happens when a user selects a menu item.
Here’s an example action to manage student records:
Enterprise
<odoo>
<data>
<record id="action_student_record" model="ir.actions.act_window">
<field name="name">Student Management</field>
<field name="res_model">student.data</field>
<field name="view_mode">list,form</field>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
Create a Student Record
</p>
</field>
</record>
</data>
</odoo>
Enterprise
● action_student_record: Unique identifier for the action.
● model="ir.actions.act_window": Indicates a window action that will
open a view.
● name: The name displayed to the user.
● res_model: The model tied to this action (in this case, student.data).
● view_mode: Defines the available views (list for list view, form for
record details).
● help: Provides guidance when no records are found.
This action allows users to manage student data through list and form
views.
Enterprise
Creating Menus
Menus in Odoo are used to navigate the system and group related features.
Here’s how to create the main menu and sub-menus for managing students:
Enterprise
<odoo>
<data>
<menuitem id="student_menu_root" name="Student Management" sequence="10">
<menuitem id="student_order_menu" name="Students" sequence="10">
<menuitem id="menu_student_records" name="Student Records"
action="action_student_record" sequence="10"/>
</menuitem>
</menuitem>
</data>
</odoo>
Enterprise
● student_menu_root: The main menu for student management.
● sequence: Defines the order in which the menu items are displayed.
● student_order_menu: A sub-menu for student-related items.
● menu_student_records: A menu item linked to the action we defined
for student records.
This menu setup allows users to access student records under the "Student
Management" section.
Enterprise
Enterprise
Extending the Menu and Action Definitions
We can extend this structure to manage additional records, such as class
information. Here’s how to create an action and menu for class records:
Enterprise
<odoo>
<data>
<!-- Action for Class Records -->
<record id="action_class_record" model="ir.actions.act_window">
<field name="name">Class Records</field>
<field name="res_model">class.record</field>
<field name="view_mode">tree,form</field>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
Manage Class Information
</p>
</field>
</record>
<!-- Menu for Class Records -->
<menuitem id="class_menu" name="Class Records" action="action_class_record"
parent="student_order_menu"/>
</data>
</odoo>
Enterprise
● action_class_record: Defines the action for class records.
● res_model="class.record": Specifies the model used for class data.
● class_menu: A sub-menu item under "Students," linked to the class
records action.
With this addition, users can easily manage both student and class
information under the same menu structure.
Enterprise
Enterprise
Conclusion
Defining menus and actions in Odoo 18 is an essential skill for customizing
the platform and enhancing the user experience. By setting up models,
configuring actions, and creating a well-organized menu structure, you can
improve workflow efficiency and ensure a smoother navigation experience
for users. Whether managing student records, class records, or other
business data, these steps will guide you in creating a functional, intuitive
Odoo application tailored to your needs.
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 Define Menu & Actions in Odoo 18 - Odoo 18 Slides

  • 1.
    How to DefineMenu & Actions in Odoo 18 Enterprise
  • 2.
    Enterprise In this slide,we will walk you through the process of defining menus and actions in Odoo 18, offering a step-by-step look at how to implement them with the necessary code. Introduction
  • 3.
    Enterprise Setting Up theModel Before working on menus and actions, we need to establish a foundational model. This model will serve as the basis for menu and action configurations. For this example, we will create a simple model to manage student information.
  • 4.
    Enterprise from odoo importmodels, fields class StudentData(models.Model): _name = "student.data" name = fields.Char(string="Name") class_name = fields.Char(string="Class") address = fields.Char(string="Address")
  • 5.
    Enterprise ● _name: Definesthe internal model name used in Odoo. ● name: A field to store the student's name. ● class_name: A field for the class the student belongs to. ● address: A field to hold the student's address. This model will store basic student information, which we will later reference in our menus and actions.
  • 6.
    Enterprise Defining Actions Actions inOdoo define how users interact with data. They specify the views (list, form, etc.) and dictate what happens when a user selects a menu item. Here’s an example action to manage student records:
  • 7.
    Enterprise <odoo> <data> <record id="action_student_record" model="ir.actions.act_window"> <fieldname="name">Student Management</field> <field name="res_model">student.data</field> <field name="view_mode">list,form</field> <field name="help" type="html"> <p class="o_view_nocontent_smiling_face"> Create a Student Record </p> </field> </record> </data> </odoo>
  • 8.
    Enterprise ● action_student_record: Uniqueidentifier for the action. ● model="ir.actions.act_window": Indicates a window action that will open a view. ● name: The name displayed to the user. ● res_model: The model tied to this action (in this case, student.data). ● view_mode: Defines the available views (list for list view, form for record details). ● help: Provides guidance when no records are found. This action allows users to manage student data through list and form views.
  • 9.
    Enterprise Creating Menus Menus inOdoo are used to navigate the system and group related features. Here’s how to create the main menu and sub-menus for managing students:
  • 10.
    Enterprise <odoo> <data> <menuitem id="student_menu_root" name="StudentManagement" sequence="10"> <menuitem id="student_order_menu" name="Students" sequence="10"> <menuitem id="menu_student_records" name="Student Records" action="action_student_record" sequence="10"/> </menuitem> </menuitem> </data> </odoo>
  • 11.
    Enterprise ● student_menu_root: Themain menu for student management. ● sequence: Defines the order in which the menu items are displayed. ● student_order_menu: A sub-menu for student-related items. ● menu_student_records: A menu item linked to the action we defined for student records. This menu setup allows users to access student records under the "Student Management" section.
  • 12.
  • 13.
    Enterprise Extending the Menuand Action Definitions We can extend this structure to manage additional records, such as class information. Here’s how to create an action and menu for class records:
  • 14.
    Enterprise <odoo> <data> <!-- Action forClass Records --> <record id="action_class_record" model="ir.actions.act_window"> <field name="name">Class Records</field> <field name="res_model">class.record</field> <field name="view_mode">tree,form</field> <field name="help" type="html"> <p class="o_view_nocontent_smiling_face"> Manage Class Information </p> </field> </record> <!-- Menu for Class Records --> <menuitem id="class_menu" name="Class Records" action="action_class_record" parent="student_order_menu"/> </data> </odoo>
  • 15.
    Enterprise ● action_class_record: Definesthe action for class records. ● res_model="class.record": Specifies the model used for class data. ● class_menu: A sub-menu item under "Students," linked to the class records action. With this addition, users can easily manage both student and class information under the same menu structure.
  • 16.
  • 17.
    Enterprise Conclusion Defining menus andactions in Odoo 18 is an essential skill for customizing the platform and enhancing the user experience. By setting up models, configuring actions, and creating a well-organized menu structure, you can improve workflow efficiency and ensure a smoother navigation experience for users. Whether managing student records, class records, or other business data, these steps will guide you in creating a functional, intuitive Odoo application tailored to your needs.
  • 18.
    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