Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Odoo 12 Development Essentials

You're reading from   Odoo 12 Development Essentials Fast-track your Odoo development skills to build powerful business applications

Arrow left icon
Product type Paperback
Published in Dec 2018
Publisher Packt
ISBN-13 9781789532470
Length 404 pages
Edition 4th Edition
Languages
Tools
Concepts
Arrow right icon
Author (1):
Arrow left icon
Daniel Reis Daniel Reis
Author Profile Icon Daniel Reis
Daniel Reis
Arrow right icon
View More author details
Toc

Table of Contents (17) Chapters Close

Preface 1. Quick Start Using the Developer Mode FREE CHAPTER 2. Preparing the Development Environment 3. Your First Odoo Application 4. Extending Modules 5. Import, Export, and Module Data 6. Models – Structuring the Application Data 7. Recordsets – Working with Model Data 8. Business Logic – Supporting Business Processes 9. External API – Integrating with Other Systems 10. Backend Views – Designing the User Interface 11. Kanban Views and Client-Side QWeb 12. Reports and Server-Side QWeb 13. Creating Website Frontend Features 14. Deploying and Maintaining Production Instances 15. Assessments 16. Other Books You May Enjoy

Creating menu items

We now have a Model to store the To-do Items, and want to have it available in the user interface. Adding a menu item will achieve that.

We will create a top-level menu item that directly opens the to-do list. Some apps, such as Contacts, can work like this, but others have submenu items, shown in the top bar.

Changes in Odoo 12
In the community edition, the menu items below the first level are now shown in the top bar, like in the EE. In previous versions, the CE presented these menu items on the left-hand side of the screen.

Menu definitions are in the Settings application, in Technical | User Interface | Menu Items:

Create a new menu item using the following values:

  1. Menu: To-do
  2. Parent Menu: (empty)
  3. In the Action field, select ir.actions.act_window, and in the selection list on the right, click Create and Edit to open a form for the related Window Actions
  4. Set the following values on the Window Actions form:
    • Action name: To-do Items
    • Object: x_todo_item (the technical name of the target Model)

At this point the Action definition should look like this:

  1. Save all the forms we opened, and the menu tree for our To-do application should be ready to use.

To see changes in the menu, we need to reload the web client. In most browsers, you can use the F5 key for this. We can now use this menu item to access and interact with the to-do items model. We haven't created any view for it yet, but the Odoo framework is nice enough to automatically generate some basic views for us:

In our case, an action was added directly to a top-level menu item, with no child menu items. But menus can be a tree of menu items, with parent/child relations. The leaf menu items have a related Action, defining what happens when it is selected. This Action Name is what will be used as the title of the presented views.

There are several Action Type available, and the most important ones are window, reports, and server actions. Window Actions are the most frequent ones, and are used to present views in the web client. Report actions are used to run reports and server actions are used to define automated tasks.

At this point, we are concerned with Window Actions that are used to display views. The Menu Item we just created for the to-do item uses a Window Actions, which was created directly from the Menu Item form. We can also view and edit it from the Settings | Technical | Actions menu options. In this particular case, we are interested in the Window Actions menu option.

In many cases, it is more convenient to use the Edit Action option in the Developer Tools, providing a convenient shortcut to edit the Window Actions that was used to access the current view.

Now we want to create our views, so that's what we will be working on in the next section.

You have been reading a chapter from
Odoo 12 Development Essentials - Fourth Edition
Published in: Dec 2018
Publisher: Packt
ISBN-13: 9781789532470
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image