In Odoo 18, model fields have various attributes that define their
behavior and how they are presented in the UI. These attributes are
set using keyword arguments in field definitions.
Below is a list of commonly used field attributes:
string
Defines the label that appears in the UI.
name = fields.Char(string="Field Name")
- name is the technical field name.
- Char is the field type.
- string is the label shown in forms and lists.
- Default: If not given, the label will be a prettified version of
the field name.
required
Makes the field mandatory. If not filled, validation will fail on
save.
name = fields.Char(string="Name", required=True)
- Default: False
- Valid values: True, False
help
Displays a tooltip when hovering over the field in the UI.
name = fields.Char(
string="Applicant Name",
help="Enter the full name of the applicant"
)
- Useful for guiding users and reducing errors.
index
Adds a database index to improve search performance.
email = fields.Char(string="Email", index=True)
- Default: False
- Use only for fields frequently used in search filters.
default
Specifies the default value for the field when a new record is
created.
country = fields.Char(string="Country", default='India')
- Can be a static value or a function.
readonly
Prevents the user from editing the field in forms.
created_on = fields.Datetime(string="Created On", readonly=True)
- Default: False
- Can be dynamic using view definitions (e.g.,
readonly="1" based on conditions).
translate
Enables field translation for multilingual interfaces.
description = fields.Text(string="Description", translate=True)
- Works with Char, Text, Selection, etc.
- Useful for content that appears in different user languages.
groups
Restricts field visibility and editability to specific user groups.
salary = fields.Float(string="Salary", groups="hr.group_hr_user")
- Provides security at the field level.
- Group XML IDs are used to define restrictions.
check_company
Ensures the field respects company boundaries in multi-company
setups.
company_id = fields.Many2one('res.company', string="Company", check_company=True)
- Helps prevent cross-company data access issues.
- Only applicable to relational fields like
Many2one.
store
Used with computed fields to indicate whether the computed value
should be saved in the database.
total = fields.Float(compute="_compute_total", store=True)
- Improves performance for frequently used computed fields.
- When
store=False, the value is recalculated
on-the-fly and not saved.