What Is Automatic & Reserved Fields in Odoo 15

What Is Automatic & Reserved Fields in Odoo 15

Odoo development helps create, edit and build the advanced features rather than the current Odoo. It will help to build new models, fields, views, and actions in odoo. Odoo fields contain the field definition and assignments of fields based on records. In odoo, out of these fields, some of them are never needed to be defined, which are automatically determined by Odoo itself; they are Automatic & Reserved ones.
This Blog helps to manage Automatic & Reserved fields.
Automatic Fields
Odoo has Automatic Fields that link models together. Moreover, these database fields are reserved and should not be modified. This is an Identifier Field; each model record has its own ID.
odoo.fields.id
This is an Identifier Field; each model record has its own ID, which should not be written as a single number.
We can see the identifier Field of each record by opening the corresponding form Open Developer Tools >> View Fields, and there is an ID field in those list views.
Access Log Fields
Access Log Fields are the next set of fields in the Automatic category.
If log_access is enabled, these fields are set and updated automatically.
It can be turned off to avoid creating or updating fields on tables that aren’t needed.
log_access is set to the same value as _auto by default. The log_access must be a Transient Model to avoid creating or updating fields. Data is still stored in the database, but only for a limited time.
odoo.fields.create_date
This Datetime field stores the date on which this record was created.
A create_date Datetime field will be present for each and every record in a model.
This creation date can be used to find specific values in other situations.
odoo.fields.create_uid
The odoo.fields.create_uid field stores the user’s name who created this record. The res.users model has a many2one field. It belongs to a create_uid field of res.users for every record. Open Developer Tools >> View Fields to see this read-only, stored field in each form.
odoo.fields.write_date
The odoo.fields.write_date field is a Datetime Read-only field. It stored when the record was last updated. This field aids us in keeping track of the records’ history. This field also contains the date of the most recent modification for each record. This field’s value contains the most recent updates for each model record.
odoo.fields.write_uid
The odoo.fields.write_uid field is a Many2one field of model res.users Stores who last updated the record, Many2one to a res.users. This many2one allows you to keep track of the history of each record in the model, as well as user information and record updates. The value of this field indicates who provides the most recent updates in each model record.
Some field names are reserved for pre-planning purposes rather than Automated fields.
On each model, these fields are set aside for when the corresponding action is required.
In Odoo, each field must have a corresponding type.
The following are certain Reserved fields.
odoo.fields.name
This field is required for all models. The name of each record is displayed in this field. It displays the naming of each record and gives the default value of _rec_name for each model. Each name field is of the Char type.
Let’s look at an example of code that shows a custom model and its field name in Char type.
class StoreIssue(models.Model):
    _name =  ‘store.isssue’
    _rec_name = ‘system_ref_no’
    System_ref_no = fields.Char(string=”System Ref No”)
odoo.fields.active
The odoo.fields.active field determines whether or not the records in the view are visible.
The value entered here determines whether or not the record will be visible in the view, as well as in most searches and listings. This field has a Boolean type and can toggle between True and False. The record is visible in views and searches if the active field is set to True. we can set the default as False or True when we install the module, based on its record works.
active = fields.Boolean('Active', default=True)
odoo.fields.State
The odoo.fields.State field gives the specific flow of the object and shows each and every progress in a record. Models have state fields that change record progress from one state to another to review the evaluation, and one of these fields must be a Selection field.
As a list of tuples, this field stores the text of the purpose that needs to change the record.
state = fields.Selection(
            [(‘draft’, ‘Draft’),
             (‘cancel’, ‘Cancel’),
             (‘transfer’, ‘Transferred’), (‘done’, ‘Done’)], ‘State’, default=’draft’, store=True)

odoo.fields.Parent_id

This field is one of the fields used by Odoo to display hierarchical relationships.

This field is used to place each record in a tree structure, similar to that of a hierarchical wave, and it has two additional fields: 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(‘fleet.vehicle.model’, string=’Model’)
Spare_parts_id = fields.One2many(‘store.issue.line’, ‘parent_id’, string=”Spare Parts”)
Odoo.fields.company_id
For multi-company purposes, the odoo.fields.company_id field is used.
This field is used when a user logs in to companies X and Y.
Odoo has a field called company_id that allows you to select a specific company in more detail.
With the model res.users, company_id has a type of Many2one.
Company_id = fields.Many2one(‘res.company’, ‘Company’, readonly=True, help=”Company”, Default=lambda self: self.env.user,company_id)
These are the certain automatic and reserved fields in Odoo.

Similar Posts

Leave a Reply

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