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

Defining the Model representation and order


Models have structural attributes defining their behavior. These are prefixed with an underscore and the most important is _name, which defines the internal global identifier for the Model.

There are two other attributes we can use. One to set the field used as a representation, or title, for the records, and another one to set the order they are presented in.

Getting ready

This recipe assumes that you have an instance ready with my_module, as described in Chapter 3, Creating Odoo Modules.

How to do it…

The my_module instance should already contain a Python file called models/library_book.py, which defines a basic model. We will edit it to add a new class-level attribute after _name:

  1. To add a human-friendly title to the model, add the following:

        _description = 'Library Book'
  2. To have records sorted first by default from newer to older and then by title, add the following:

        _order = 'date_release desc, name'
  3. To use the short_name field as the record...