Looking again at our module design, we have these relationships:
- Each task has a stage. That's a many-to-one relationship, also known as a foreign key. The inverse is a one-to-many relationship, meaning that each stage can have many tasks.
- Each task can have many tags. That's a many-to-many relationship. The inverse relationship, of course, is also a many-to-many, since each tag can be in many tasks.
The following entity relationship diagram can help visualize the relationships we are about to create in the model. The lines ending with a triangle represent the many sides of the relationships:
Let's add the corresponding relationship fields to the To-Do tasks in our todo_task_model.py file:
class TodoTask(models.Model): _inherit = 'todo.task'
stage_id = fields.Many2one('todo.task.stage', 'Stage&apos...