Odoo 17 Model Attributes

December 19, 2023

The Odoo model class represents a specific data relationship or table in Odoo. Each Odoo model corresponds to a distinct database table, encompassing all the necessary attributes and behaviors for effective data management. It encapsulates all the essential fields and functionalities for storing and managing the associated data.

Models can be divided into three types:

1. Abstract model

2. Transient Model

3. Models


In regular database-persisted models, fields are declared as attributes

from odoo import API, fields, models

class ClassTest(models.Model):

   _name = 'class.test

Abstract Model

All Odoo models derive from this superclass, which is the primary superclass for conventional database-persisted models,

from odoo import api, fields, models, _

class ClassTest(models.AbstractModel):

   _name = 'class.test

Transient model

The superclass represents transient records that are temporary and subject to regular vacuuming.

from odoo import API, fields, models, _

class ClassTest(models.TransientModel):

   _name = 'class.test

Odoo 17 Model Attributes

In Odoo, model attributes are specified either during model creation or when using an existing model.

1 . _name

   Within the module namespace, the model name is expressed in dot notation.

_name = 'model.test

2 . _auto (default = true)

If _auto is set to false, the init() method needs to be overridden to manually create the database table. By default, it is true for models and transient models and False for abstract models.

3. _log_access (default = auto)

The log access parameter specifies whether or not access logs should be generated and updated automatically. When the value of log access is set to false, the fields ‘create_date’, ‘create_uid’, ‘write_uid’, and ‘write_date’ are not automatically populated into the database.

4. _abstract

An abstract model is one whose attributes are true by default, while a regular or transient model is one whose attributes are false by default.

5. _transient

Transient models are defined by this attribute. By default, it is set to ‘true’ for transient models and ‘false’ for regular or abstract models.

6. _check_company_auto (default = false)

If the check_company attribute is true on relational fields, invoke the check company function during write and create operations to ensure company consistency.

7._inherit = ()

This attribute is used for both classical and extension types of inheritance when working with an existing model in the database.

8. _order(default = ‘id’)

This field orders search results by default

Data models in Odoo are defined by attributes that describe their behavior, characteristics, and how records are handled and presented.

"Unlock the Full Potential of Your Business with Odoo ERP!"

"Get a Cost Estimate for Your ERP Project, Absolutely FREE!"

Get a Free Quote

Leave a Reply

Your email address will not be published. Required fields are marked *