Book Image

Odoo 12 Development Essentials - Fourth Edition

By : Daniel Reis
Book Image

Odoo 12 Development Essentials - Fourth Edition

By: Daniel Reis

Overview of this book

Odoo is one of the best platforms for open source ERP and CRM. Its latest version, Odoo 12, brings with it new features and updates in Python packages to develop more customizable applications with additional cloud capabilities. The book begins by covering the development essentials for building business applications. You will start your journey by learning how to install and configure Odoo, and then transition from having no specific knowledge of Odoo to being ready for application development. You will develop your first Odoo application and understand topics such as models and views. Odoo 12 Development Essentials will also guide you in using server APIs to add business logic, helping you lay a solid foundation for advanced topics. As you progress through the chapters, you will be equipped to build and customize your applications and explore the new features in Odoo 12, such as cloud integration, to scale your business applications. You will get insights into building business logic and integrating various APIs into your application. By the end of the book, you will be able to build a business application from scratch by using the latest version of Odoo.
Table of Contents (22 chapters)
Title Page
Packt Upsell
Foreword
Contributors
Preface
Index

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.

Note

Changes in Odoo 12In 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.

 

Note

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.