I'm trying to develop simple library app with Odoo but I get an error with manytomany relationship.
Here are classes:
class Book(models.Model):
_name = "library.book"
publisher_id = fields.Many2one(comodel_name="library.book.partner", string="Publisher")
author_ids = fields.Many2many(comodel_name="library.book.partner", relation='library_book_profile_partner_authors', column1='book_id', column2='partner_id', string="Authors")
class Partner(models.Model):
_name = "library.book.partner"
_inherit = "res.partner"
published_book_ids = fields.One2many("library.book", "publisher_id", string="Published Books")
book_ids = fields.Many2many("library.book", 'partner_books', 'book_id', 'partner_id', string="Authored Books")
This is the error I always get when installing the app
TypeError: Many2many fields library.book.partner.channel_ids and res.partner.channel_ids use the same table and columns
Someone can help to solve this please ?
It's the
_inherit = "res.partner". Odoo is inheriting the model with a new model name which means it's creating a new table and copying all fields. Forchannel_idsit's trying to create the many2many "join" table, but with the same name as inres.partner. That happens because the table name is directly defined in the field (mail_channel_partner).So to solve the problem you have to "redefine"
channel_idson your new model again and change the table name, for example like: