Adding relational fields to a Model

Relations between Odoo Models are represented by relational fields. We can have three different types of relations:

  • many-to-one, commonly abbreviated as m2o
  • one-to-many, commonly abbreviated as o2m
  • many-to-many, commonly abbreviated as m2m

Looking at the Library Books example, we can see that each book can have one publisher, so we can have a many-to-one relation between books and publishers.

From the publisher's point of view, each publisher can have many books. So, the previous many-to-one relation implies a one-to-many reverse relation.

Finally, there are cases where we can have a many-to-many relation. In our example, each book can have several (many) authors. Also, inversely, each author can have written many books. Looking at it from either side, this is a many-to-many relation.