<p>user_rel_ids=fields.Many2many(comodel_name='课程',
relation='用户课程'u rel',
column1='用户id',
column2='课程id')</p>
<p>或者</p>
<pre><code>user_rel_id = fields.Many2many('course')
</code></pre>
<p>用于填充数据(用于添加新关系)</p>
<pre><code>user_rel_id = [(4,course_id)]
</code></pre>
<p>根据<a href="http://odoo4u.blogspot.com/2014/10/orm-methods.html" rel="nofollow noreferrer">http://odoo4u.blogspot.com/2014/10/orm-methods.html</a>,上面写着:
类的文档中有一个完整的选项列表。
同样的事情也适用于2万人</p>
<blockquote>
<p>For a <strong>many2many</strong> and <strong>one2many</strong> field, a list of tuples is
expected. Here is the list of the tuple that is accepted, with the
corresponding semantics:</p>
<p><code>(0, 0, { values })</code> link to a <strong>new record</strong> that needs to be
created with the given values dictionary</p>
<p><code>(1, ID, { values })</code> <strong>update</strong> the linked record with id = ID (write
values on it)</p>
<p><code>(2, ID)</code> remove and <strong>delete</strong> the linked record with id = ID (calls
unlink on ID, that will delete the object completely, and the link to
it as well)</p>
<p><code>(3, ID)</code> cut the link to the linked record with id = ID (<strong>delete the
relationship</strong> between the two objects but does not delete the target
object itself)</p>
<p><code>(4, ID)</code> <strong>link</strong> to existing record with id = ID (adds a
relationship)</p>
<p><code>(5)</code> <strong>unlink all</strong> (like using (3, ID) for all linked records)</p>
<p><code>(6, 0, [IDs])</code> <strong>replace</strong> the list of linked IDs (like using (5)
then (4,ID) for each ID in the list of IDs)</p>
</blockquote>