Hi,
I am trying to create a model entry in my controller, which has a many2many field. The creating works but the values I added to the many2many field are not there. What is wrong?
Model definition:
class Paper(models.Model):
_name = 'paper_submission.paper'
title = fields.Char(string='Title', required='True')
author_ids = fields.Many2many('paper_submission.author', string='Authors', relation="paper_submission_paper_author_relation")
references model:
class Author(models.Model):
_name = 'paper_submission.author'
first_name = fields.Char()
last_name = fields.Char()
Code for creating the model entry:
orm_paper = registry.get('paper_submission.paper')
paper_info = {"title: title, author_ids": author_ids}
paper_id = orm_paper.create(cr, SUPERUSER_ID, paper_info, context=context)
where author_ids is a list of ids, like [1,2]
SOLUTION: orm_paper.create({'title': title, 'author_ids': [(6, 0, author_ids)]}) using: (6, _, ids) triplet from the Odoo docs: "Values marked as _ in the list above are ignored and can be anything, generally 0 or False."