December 2018
Beginner to intermediate
404 pages
10h 14m
English
A many-to-many relationship is used when we have a to-many relationship on both sides. Taking our library books example again, we can find a many-to-many relationship between books and authors: each book can have many authors, and each author can have many books.
On the books side, we have on the library.book model:
class Book(models.Model) _name = 'library.book' author_ids = fields.Many2many( 'res.partner', string='Authors')
On the authors side, we can add the inverse relation to the res.partner model:
class Partner(models.Model): _inherit = 'res.partner'
book_ids = fields.Many2many( 'library.book', string='Authored Books')
The Many2many minimal signature accepts one positional argument for the related model ...
Read now
Unlock full access