
Introduction
In Odoo development, connecting data is everything. Whether you are linking a sales order to a customer, an employee to a department, or an invoice to a partner, relational fields define how your data models communicate.
Odoo provides three types of relational fields (Many2one, One2many, and Many2many), but the most common source of confusion, especially for developers new to Odoo, is understanding the difference between Many2one and One2many.
In this guide, we’ll break down how these two fields work, how they are implemented in code, and – most importantly – when to use each one in real-world Odoo 18 customizations.

1. The Many2one Field: The Direct Link
A Many2one field is used when multiple records in your current model need to reference a single record in another model (the co-model).
How it works
At the database level, a Many2one field creates a Foreign Key (FK) column that stores the ID of the related record. In the Odoo user interface, this appears as a searchable dropdown.
Syntax & Example:
Syntax
field_id = fields.Many2one('comodel.name', string='Field Label')
For example: Multiple employees belonging to one department
department_id = fields.Many2one('hr.department', string='Department')
Pro Tip: You can easily access data from the related record using “dot notation.” For example, employee.department_id.name fetches the name of the department directly.
Key Parameters
- comodel_name: (Mandatory) The technical name of the model you are linking to.
- ondelete: Determines what happens if the related record is deleted.
- cascade: Deletes this record too.
- set null: Keeps this record but clears the field.
- restrict: Prevents the deletion of the parent record.
- domain: Filters the records the user can select (e.g., only show active departments).
- tracking=True: Logs changes to this field in the chatter.
2. The One2many Field: The Inverse Relation
A One2many field represents the inverse side of a Many2one relationship. It allows one record in the current model to display multiple related records from another model.
How it works
Unlike Many2one, a One2many field does not create a database column. Instead, it acts as a virtual field that fetches all records in the target model whose Many2one field points back to the current record. In the UI, One2many fields are typically displayed as:
- A list (Tree view)
- A Kanban view
- A Notebook tab
Syntax & Example
field_ids = fields.One2many('comodel.name', 'inverse_name', string='Field Label')
For example: One Partner having many Invoices
invoice_ids = fields.One2many('account.move', 'partner_id', string='Invoices')
In this case, partner_id is the Many2one field inside the account.move model.
Key Parameters
- comodel_name: (Mandatory) The target model.
- inverse_name: (Mandatory) The Many2one field in the target model that links back here.
- context: Useful for pre-filling values when creating new records from the list (e.g.,
{'default_type': 'out_invoice'}).
Comparison at a Glance
| Feature | Many2one | One2many |
| Database Structure | Creates a physical Foreign Key column. | Virtual; no column created. |
| UI Representation | Dropdown / Search widget. | List (Tree) view or Kanban. |
| Storage | Stores a single ID. | Stores a collection of records. |
| Mandatory Attributes | comodel_name | comodel_name AND inverse_name |
Which one should you use?
- Use Many2one if you are “looking up” to a parent
- Example: “Who is the manager of this project?”).
- Use One2many if you want to see a list of children from the parent’s perspective
- Example: “Show me all tasks inside this project”).
Understanding these relationships is the foundation of clean Odoo 18 development. By choosing the right field, you ensure your data remains organized, searchable, and logically connected.
Conclusion
Understanding the difference between Many2one and One2many is foundational to clean, scalable Odoo 18 development. Choosing the correct relational field impacts not only database structure, but also performance, usability, and long-term maintainability. As a rule of thumb:
- Many2one defines the relationship
- One2many visualizes it
When used correctly, these fields ensure your data remains structured, searchable, and logically connected – making both your codebase and user experience significantly stronger.
If you’re planning to customize, scale, or optimize your Odoo implementation, Zen8Labs is here to help. Our team supports businesses at every stage – from system design and development to long-term optimization and support.
👉 Reach out to Zen8Labs to explore how we can support your next projects.
Duong Phi, Software Engineer