Odoo 如何在文件中添加多个21数据

Odoo 如何在文件中添加多个21数据,odoo,odoo-12,Odoo,Odoo 12,我有一些相互依赖的模型,它们之间有很多关系 我已经设置了所有视图,但是现在我正在通过数据文件添加数据来测试我发现的所有内容,我不知道如何添加这些记录 我应该执行一次运行,基本上声明记录,同时保持关系值为null,然后稍后使用关系更新记录吗 另外,关系字段的值应该是多少?阵列还是什么?您始终可以使用内置模块的演示和数据文件作为参考 如您所见,category\u id是Many2many字段(同样适用于one2many字段) 要了解eval属性的值,请阅读以下内容: (0, 0, { val

我有一些相互依赖的模型,它们之间有很多关系

我已经设置了所有视图,但是现在我正在通过数据文件添加数据来测试我发现的所有内容,我不知道如何添加这些记录

我应该执行一次运行,基本上声明记录,同时保持关系值为null,然后稍后使用关系更新记录吗


另外,关系字段的值应该是多少?阵列还是什么?

您始终可以使用内置模块的演示和数据文件作为参考

如您所见,
category\u id
Many2many
字段(同样适用于
one2many
字段)


要了解
eval
属性的值,请阅读以下内容:

(0, 0,  { values })    link to a new record that needs to be created with the given values dictionary
(1, ID, { values })    update the linked record with id = ID (write *values* on it)
(2, ID)                remove and delete the linked record with id = ID (calls unlink on ID, that will delete the object completely, and the link to it as well)
(3, ID)                cut the link to the linked record with id = ID (delete the relationship between the two objects but does not delete the target object itself)
(4, ID)                link to existing record with id = ID (adds a relationship)
(5)                    unlink all (like using (3,ID) for all linked records)
(6, 0, [IDs])          replace the list of linked IDs (like using (5) then (4,ID) for each ID in the list of IDs)
对于其值中的
ref
函数(即这部分
ref('employee_category_2')
),它是加载数据文件时评估的
python
函数,它采用相关字段的XML recordID(有时您可能需要使用外部ID—例如,在本例中,记录的外部ID为
hr.employee\u category\u 2


引用:

对于
多个
字段,您只需使用
ref('XMLID')
作为
field
XML元素的
eval
属性的值,就像在视图定义的
inherited\u id
属性中引用inherited视图一样。感谢您的回答,我将尝试一次创建所有基本记录,然后通过(6,0,[id])添加记录