KEMBAR78
Automatic and Reserved Fields in odoo - Odoo Slides | PPTX
Automatic and Reserved
Fields in odoo 17
Enterprise
Introduction
Enterprise
In this slide we’ll discuss the Automatic and Reserved fields in
odoo 17. Odoo includes different types of fields designed to create
relationships between different models and regulate data access.
Automatic fields in Odoo are automatically generated by the
system and do not require an explicit definition in the model. On
the other hand, reserved fields are system-defined fields that
cannot be used as custom field names. These fields are primarily
reserved for system-generated information or metadata and serve
specific functions within the system.
Enterprise
AUTOMATIC FIELDS
● id
It is an odoo's field designed to indicate the database column
responsible for storing a unique identifier (ID) for each record
within the model. Each record has its own distinct ID, which is
automatically set upon creation and remains unchangeable
thereafter. Debug mode must be enabled to access and view this
field.
● create_date
This is a system-defined field within Odoo designed to store the
date and time a record was created in the database. As an
automatic field, it is generated and managed by the system and
remains immutable by the user.
Enterprise
● write_date
This field represents the date and time the record last updated. As a
record undergoes editing, this field is automatically updated to
capture the appropriate date and time. It can be used to filter records
based on their last update timestamp or to display the last update
date and time in a record form or report. This field is stored as a read-
only attribute in each record.
● create_uid
This is a many2one field associated with the comodel 'res.users,'
capturing the user_id of the record creator. Automatically populated
upon the creation of a new record, this system field which is readonly,
facilitates tracking the user responsible for a specific record. It
restricts record creation to specific users.
Enterprise
● write_uid
This is a many2one field associated with the 'res.users' comodel that
stores the user_id of the last record modifier. This system field, is
automatically updated whenever a record is modified and is used to
track the user responsible for the latest changes.
● Access Log fields
These fields are automatically generated and updated when
log_access is set to true. It is utilized for monitoring changes to
records and identifying the users responsible for those modifications.
Disabling log_access prevents the unnecessary creation or update of
these fields in tables where they are not required. log_access is set to
true in transient models, which store data temporarily and are subject
to periodic deletion.
Enterprise
RESERVED FIELDS
● name
This field is a required attribute on every character type model. It is
used to display the title of each record and is commonly used to
store labels for objects or entities in the system such as customers,
products or employees.
Typically, this field is presented as the primary label for records in
various views and forms.
Enterprise
RESERVED FIELDS
● active
This field controls the visibility of the view. The odoo.fields.active
refers to a Boolean field utilized for marking records as active or
inactive. When a record is marked as inactive, it becomes
‘hidden’ in most views and reports. However, the recording data
continues to exist in database and can be retrieved and
reactivated later if needed.
Example:
active = fields.Boolean('Active', default=True)
In this example, when the active field is set to True, the records
will be visible in views and reports.
Enterprise
● state
This field is a selection field used to indicate a state or condition for an
item in the model. It is commonly used to track the progress or
workflow of a record as it goes through various stages such as "draft",
"submit" etc. Each state value is defined as a tuple that contains a
string label and a unique identifier.
Example:
state = fields.Selection( selection=[ ('draft', 'Draft'), (done, Done)],
string='Status', required=True, readonly=True, copy=False,
tracking=True, default='draft')
The 'state' field helps articulate various actions or behaviors triggered
when a record transitions from one state to another.
Enterprise
● company_id
Odoo’s field company_id facilitates multi-company functionality,
representing a many-to-one field which refers to ‘res.company’
model is used to associate a record in a model with a specific
company. This allows multiple companies to use the same odoo
instance while keeping their data and configurations separate.
Example:
company_id = fields.Many2one('res.company', string="Company",
default=lambda self: self.env.user.company_id)
company_id ensures accurate assignment of transactions and
documents to the respective company.
For More Info.
Check our company website for related blogs
and Odoo book.
Check our YouTube channel for
functional and technical videos in Odoo.
Enterprise
www.cybrosys.com

Automatic and Reserved Fields in odoo - Odoo Slides

  • 1.
    Automatic and Reserved Fieldsin odoo 17 Enterprise
  • 2.
    Introduction Enterprise In this slidewe’ll discuss the Automatic and Reserved fields in odoo 17. Odoo includes different types of fields designed to create relationships between different models and regulate data access. Automatic fields in Odoo are automatically generated by the system and do not require an explicit definition in the model. On the other hand, reserved fields are system-defined fields that cannot be used as custom field names. These fields are primarily reserved for system-generated information or metadata and serve specific functions within the system.
  • 3.
    Enterprise AUTOMATIC FIELDS ● id Itis an odoo's field designed to indicate the database column responsible for storing a unique identifier (ID) for each record within the model. Each record has its own distinct ID, which is automatically set upon creation and remains unchangeable thereafter. Debug mode must be enabled to access and view this field. ● create_date This is a system-defined field within Odoo designed to store the date and time a record was created in the database. As an automatic field, it is generated and managed by the system and remains immutable by the user.
  • 4.
    Enterprise ● write_date This fieldrepresents the date and time the record last updated. As a record undergoes editing, this field is automatically updated to capture the appropriate date and time. It can be used to filter records based on their last update timestamp or to display the last update date and time in a record form or report. This field is stored as a read- only attribute in each record. ● create_uid This is a many2one field associated with the comodel 'res.users,' capturing the user_id of the record creator. Automatically populated upon the creation of a new record, this system field which is readonly, facilitates tracking the user responsible for a specific record. It restricts record creation to specific users.
  • 5.
    Enterprise ● write_uid This isa many2one field associated with the 'res.users' comodel that stores the user_id of the last record modifier. This system field, is automatically updated whenever a record is modified and is used to track the user responsible for the latest changes. ● Access Log fields These fields are automatically generated and updated when log_access is set to true. It is utilized for monitoring changes to records and identifying the users responsible for those modifications. Disabling log_access prevents the unnecessary creation or update of these fields in tables where they are not required. log_access is set to true in transient models, which store data temporarily and are subject to periodic deletion.
  • 6.
    Enterprise RESERVED FIELDS ● name Thisfield is a required attribute on every character type model. It is used to display the title of each record and is commonly used to store labels for objects or entities in the system such as customers, products or employees. Typically, this field is presented as the primary label for records in various views and forms.
  • 7.
    Enterprise RESERVED FIELDS ● active Thisfield controls the visibility of the view. The odoo.fields.active refers to a Boolean field utilized for marking records as active or inactive. When a record is marked as inactive, it becomes ‘hidden’ in most views and reports. However, the recording data continues to exist in database and can be retrieved and reactivated later if needed. Example: active = fields.Boolean('Active', default=True) In this example, when the active field is set to True, the records will be visible in views and reports.
  • 8.
    Enterprise ● state This fieldis a selection field used to indicate a state or condition for an item in the model. It is commonly used to track the progress or workflow of a record as it goes through various stages such as "draft", "submit" etc. Each state value is defined as a tuple that contains a string label and a unique identifier. Example: state = fields.Selection( selection=[ ('draft', 'Draft'), (done, Done)], string='Status', required=True, readonly=True, copy=False, tracking=True, default='draft') The 'state' field helps articulate various actions or behaviors triggered when a record transitions from one state to another.
  • 9.
    Enterprise ● company_id Odoo’s fieldcompany_id facilitates multi-company functionality, representing a many-to-one field which refers to ‘res.company’ model is used to associate a record in a model with a specific company. This allows multiple companies to use the same odoo instance while keeping their data and configurations separate. Example: company_id = fields.Many2one('res.company', string="Company", default=lambda self: self.env.user.company_id) company_id ensures accurate assignment of transactions and documents to the respective company.
  • 10.
    For More Info. Checkour company website for related blogs and Odoo book. Check our YouTube channel for functional and technical videos in Odoo. Enterprise www.cybrosys.com