Book Image

Odoo Development Cookbook

By : Holger Brunn, Alexandre Fayolle, Daniel Reis
Book Image

Odoo Development Cookbook

By: Holger Brunn, Alexandre Fayolle, Daniel Reis

Overview of this book

Odoo is a full-featured open source ERP with a focus on extensibility. The flexibility and sustainability of open source is also a key selling point of Odoo. It is built on a powerful framework for rapid application development, both for back-end applications and front-end websites. The book starts by covering Odoo installation and administration, and provides a gentle introduction to application development. It then dives deep into several of the areas that an experienced developer will need to use. You’ll learn implement business logic, adapt the UI, and extend existing features.
Table of Contents (23 chapters)
Odoo Development Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Adding a menu item and window action


The most obvious way to make a new feature available to the users is by using a menu item. When you click on a menu item, something happens. This recipe walks you through how to define that something.

We will create a top level menu displaying a sub menu in the left hand menu bar, opening a list of all the customers.

This can also be done using the web user interface, via the settings menu, but we prefer to use XML data files since this is what we'll have to use when creating our addon modules.

How to do it...

In an XML data file of our addon module, perform the following steps:

  1. Define an action to be executed:

    <act_window id="action_all_customers"
                name="All customers"
                res_model="res.partner"
                view_mode="tree,form"
                domain="[('customer', '=', True)]"
                context="{'default_customer': True}"
                limit="80" />
    
  2. Create the menu structure:

    <menuitem id="menu_custom_toplevel"
              name=...