Manifest Academy

Home › Curriculum › Odoo Developer › Relational fields: Many2one, One2many and Many2many

The ORM · 16 min · 17–20

Relational fields: Many2one, One2many and Many2many

Declaring relations, ondelete, domains, commands for writing x2many values, and relation tables.

In this lesson

Key points

Real-world example

A script used Command.delete instead of Command.unlink to remove tags from contacts and deleted the tags themselves from the database. Restoring from the morning backup on a copy and re-running with unlink taught the team the difference permanently.

Questions and answers

What's the tuple equivalent of Command.set([1,2])?

(6, 0, [1, 2])

Why name a Many2many relation table explicitly?

When two Many2many fields link the same two models, or for clarity across modules.

Read the full lesson, worked example and quiz