O'Reilly logo

Odoo Development Cookbook by Daniel Reis, Alexandre Fayolle, Holger Brunn

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required