Relations¶
Relations connect records across models. Follow the relation target in each model page to understand the surrounding business graph.
Relation types¶
| Type | Meaning | Typical read value |
|---|---|---|
many2one |
This record points to zero or one target record | false or [id, display_name] |
one2many |
Target records point back to this record | List of target IDs |
many2many |
Both sides can link to multiple records | List of target IDs |
For example, the partner_id field on account.move points to res.partner, while its line_ids field points to journal items in account.move.line.
Write many2one values¶
Send the related numeric ID or false:
Write collection relations¶
Odoo uses command triples for one2many and many2many updates:
| Command | Form | Purpose |
|---|---|---|
| Create | [0, 0, values] |
Create and link a new target record |
| Update | [1, id, values] |
Update a linked record |
| Delete | [2, id, 0] |
Delete the target record and relation |
| Unlink | [3, id, 0] |
Remove the relation without necessarily deleting the target |
| Link | [4, id, 0] |
Link an existing record |
| Clear | [5, 0, 0] |
Remove all links |
| Set | [6, 0, ids] |
Replace the complete link set |
The exact deletion behavior depends on the relation and its inverse field. Review the official ORM command reference before using delete, unlink, clear, or set commands.
Avoid blind replacement
A set command can remove links added by users or other integrations. Read the current value, apply a deliberate change, and handle concurrent updates.