0
votes

Is there any explanation with example of many2many fields? What is the difference between relational tables and models ??

1
Have you checked the docs? what exactly are you looking for?Axel Mendoza

1 Answers

1
votes

suppose you have two table teacher and student... student has multiple teacher and teacher also has multiple students so here we can not apply many2one and many2one relationship so we need to add many2many relationship on this two tables...

suppose in odoo we have two model 'student.student' and 'teacher.teacher' so we can apply many2many relationship like this in student.student model

techer_ids = fields.Many2many('teacher.teacher', 'student_teacher_rel', string='Teachers')

how it works, it will create different table in database with name student_teacher_rel . this table has two column teacher_id and student_id both are foreign key of student table and teacher table... so we can easily manage relationship between them...