How it works...

The first step adds a friendlier description title to the model's definition. This is not mandatory, but can be used by some addons. For instance, it is used by the tracking feature in the mail addon module for the notification text when a new record is created. For more details, refer to Chapter 13, Automation and Workflows.

By default, Odoo orders the records using the internal id value. However, this can be changed to use the fields of our choice by providing an _order attribute with a string containing a comma-separated list of field names. A field name can be followed by the desc keyword to have it sorted in reverse order.

Only fields stored in the database can be used. Non-stored computed fields can't be used to sort records.

The syntax for the _order string is similar to SQL ORDER BY clauses, although it's stripped down. For instance, special clauses such as NULLS FIRST are not allowed.

Model records have a representation used when they are referenced from other records. For example, a user_id field with the value 1 represents the Administrator user. When displayed in a form view, Odoo will display the username rather than the database ID. By default, the name field is used. In fact, that is the default value for the _rec_name attribute, and that's why it's convenient to have a name field in our models.

If no name field exists in the model, a representation is generated with the model and record identifiers, similar to (library.book, 1).
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.131.62