Open Source On-demand (Odoo) has a big number of users. Of course, they have their code pattern or abbreviations that may you don't know, or maybe you are lazy to looking on it, why there are abbreviations and code pattern? Check it out. 👇🏻
Prefix Model
In here, we will talk about prefixes that are commonly used in models in odoo.
Prefix ir
When you open odoo codes, You must have often seen models with the name prefix ir, for example `ir.attachment`, `ir.ui.view`, and so on. Do you know that ir is abrevation from Information Resource?
And in general, models with the prefix ir are part of the odoo framework that handles many technical aspects. For example, ir.ui.view, this model handle the UI display, or ir.attachment that used to handle files.
The res Prefix
The res prefix is short from resource. The model that usually uses this prefix is the resource data from a business. It can be said that this is important data for a business, and is usually used throughout the odoo module system. For example:
- res.users: which is data for authentication which is an important data source for a business.
- res.company: which is important data for managing companies in the application.
Field Relational Suffix
Here we will discuss about relational field suffix. Which later we will mostly use as a sign that the field is a field that is related to another model.
Suffix untuk many2one
In odoo, usually the suffix for many2one fields is _id. Why should there be _id? Because, odoo also stores your fields in the database in integer format, which if later not marked with the _id suffix, then reading the columns in the database will feel confusing. Example of using fields:
from odoo import fields, models
class YourModel(models.Model):
_name="your_module.your_model"
user_id = fields.Many2one("res.users") #example field ✅
attachment_id = fields.Many2one("ir.attachment") #example field ✅
Suffix untuk one2many dan many2many
In odoo, usually one2many and many2many fields use the suffix _ids. Why must there be _ids? Because it gives a symbol that the one related to the field is compound or can be more than one data. Example of using fields:
from odoo import api, fields, models
class DailyStandup(models.Model):
_name = "agile.daily_standup"
_description = "Daily Standup"
name = fields.Char(tracking=True)
user_ids = fields.One2many(
comodel_name="agile.daily_standup_user", inverse_name="daily_standup_id") #One2many example
user_leader_candidate_ids = fields.Many2many(
comodel_name="res.users",
string="Leader Candidate",
relation="daily_standup_user_leader_candidate") #Many2many example