One2many
and Many2many
use a special “commands” format to manipulate the set of records stored in/associated with the field.
One2many和Many2many使用特殊的“命令”格式来操纵存储在字段中/与字段相关联的记录集。
This format is a list of triplets executed sequentially, where each triplet is a command to execute on the set of records. Not all commands apply in all situations. Possible commands are:
此格式是按顺序执行的三元组列表,其中每个三元组是在记录集上执行的命令。 并非所有命令都适用于所有情况。 可能的命令是:
(0, _, values)
adds a new record created from the provided value
dict.
添加从提供的值dict创建的新记录。
(1, id, values)
updates an existing record of id id
with the values in values
. Can not be used in create()
.
使用值中的值更新 id id的现有记录。 不能在create()中使用。
(2, id, _)
removes the record of id id
from the set, then deletes it (from the database). Can not be used in create()
.
从集合中删除 id id
的记录,然后删除它(从数据库中)。 不能在create()中使用。
(3, id, _)
removes the record of id id
from the set, but does not delete it. Can not be used on One2many
. Can not be used in create()
.
从集合中删除 id id
的记录,但不删除它。 不能在One2many上使用。 不能在create()中使用。
(4, id, _)
adds an existing record of id id
to the set. Can not be used on One2many
.
将id id
的现有记录添加到集合中。 不能在One2many上使用。
(5, _, _)
removes all records from the set, equivalent to using the command 3
on every record explicitly. Can not be used on One2many
. Can not be used in create()
.
从集合中删除所有记录,相当于在每条记录中明确使用命令3。 不能在One2many上使用。 不能在create()中使用。
(6, _, ids)
replaces all existing records in the set by the ids
list, equivalent to using the command 5
followed by a command 4
for each id
in ids
.
替换ids列表中集合中的所有现有记录,相当于使用命令5,后跟命令4,用于id中的每个id。
Values marked as _
in the list above are ignored and can be anything, generally 0
or False
.
上面列表中标记为_的值将被忽略,可以是任何值,通常为0或False。