Enable Dark Mode!
By: Mily Shajan

Automatic and Reserved Fields in Odoo 14

Odoo has different kinds of fields that help to manage accesses and create bonds between different models. Odoo has Automatic and Reserved Fields which also create bonds between models. In addition, these Fields are reserved in the database and they should not be written to.
In this blog, we will discuss the functioning of the Automatic and Reserved Fields in Odoo 
Automatic Fields
Initially let's discuss the Automatic fields in Odoo, some of the Automatic fields in Odoo are described below:
This is an Identifier Field, for each record they have a unique ID in its model. Moreover, in each model and for each and every record they have their own ID and it shouldn’t be written one.
We can see the identifier Field of each record by opening the corresponding form Open Developer Tools >> View Fields and there exists an ID field in those list views.
Access Log Fields.
The next set of fields belonging under the Automatic fields are Access Log Fields. These are the fields that are automatically created and updated if  log_access becomes True.
Moreover, we can set it as False in the cases where it is not useful. In order to avoid the creation or updating of fields, the log_access  must be a Transient Model. Where data is still stored in the Database, but it is expected to be temporary.
This field stores the date when this record is created, it is a Datetime field. For each and every record in a model, there will be a create_date Datetime field. This creation date can be used in some other conditions to find certain values.
The Odoo.fields.create_uid field stores the user's name who created this record. It is a many2one field of res.users model. For each and every record it belongs to a create_uid field of res.users. This read-only, stored field can be seen in each form as Open Developer Tools >> View Fields.
The Odoo.fields.write_date field is a Datetime Read-only field, which stores the date of the last modification in the record. This field helps us to track the history of the records. Moreover, for each and every record this field gives the date of the last modification. Value in this field gives the latest updates in each and every record of the model.
The Odoo.fields.write_uid field is a Many2one field of model res.users which stores user data of who writes the last modification in the record. This many2one enables to track the history of each record in the model, about user details, and updating of the records. This field’s value gives the data of who gives the latest updates in each and every record of the model.
Some of the field names are reserved for pre-planning than that of Automated fields. These fields are reserved on each model for when the corresponding action is needed. For each field, it needs a corresponding type in Odoo. Let’s go through a few of them. The following are certain Reserved fields.
This field is necessary for each model. This field displays the name of each record. It gives the default value of _rec_name for each model, it displays the naming of each record. The type of each name field is Char.
For example let’s illustrate a code, which shows a custom model and its field name with Char type.
class StudentActivity(models.Model):
   _name = 'student.activity'
   _rec_name = 'name'
   name = fields.Char(string="Address")
The Odoo.fields.active field gives the Visibility of the records in the view. The value given in this field determines the record to be visible in the view also to show in most searches and listings. This field has a type of Boolean and can toggle as either True or False. If the active field is set to True the record is visible in views and searches. Boolean fields can toggle the value based on the user’s requirements, we can set default as False or True when we install the module, based on its record works.
active = fields.Boolean('Active', default=True)
The Odoo.fields.State field gives the specific flow of the object and shows each and every progress in a record. Models have some state fields and change record progress from one state to another to review the evaluation and it must be a Selection field. This field stores the text of the purpose that needs to change the record as a list of tuples.
state = fields.Selection([
   ('draft', 'Draft'),
   ('done', 'Completed'),
   ('cancel', 'Cancelled'), ], 'State', default='draft',
Odoo uses some fields to show hierarchical relations, this field is one of them. This field helps to set each record in a tree structure as like in a hierarchical wave, which has two add-on fields such as parent_left and parent_right. Also, the child of the parent_id has a child_of operator domain. The parent_id has a type of Many2one and child_of has One2many.
parent_id = fields.Many2one('hospital.patient', string='Patient Card',
history_ids = fields.One2many('op.ticket', 'parent_id',
                                string="op history")
The Odoo.fields.company_id field is used for multi-company purposes. This field is used when the user logged in to both companies X and Y. Odoo provides a field company_id which helps to select a particular company in detail. Company_id has a type of Many2one with the model res.users.
company_id = fields.Many2one('res.company', string='Company', required=True,
                            default=lambda self: self.env.company)
These are the certain automatic and reserved fields in Odoo.

If you need any assistance in odoo, we are online, please chat with us.


Leave a comment



Cybrosys Technologies Pvt. Ltd.
Neospace, Kinfra Techno Park
Kakkancherry, Calicut
Kerala, India - 673635



Cybrosys Limited
Alpha House,
100 Borough High Street, London,
SE1 1LB, United Kingdom



Cybrosys Technologies Pvt. Ltd.
1st Floor, Thapasya Building,
Infopark, Kakkanad,
Kochi, India - 682030.



Cybrosys Techno Solutions
The Estate, 8th Floor,
Dickenson Road,
Bangalore, India - 560042

Send Us A Message