解释 OpenERP 7.0 中的安全性以及 (6,0) 和 (4) 的用途是什么?

Explain Security in OpenERP 7.0 and What is the use of (6,0) and (4)?

我看过这个

eval="[(6, 0, ref('test_security.base_security_access)])]" 

eval="[(4, [ref('test_security.base_security_access')])]"

在 OpenERP 7.0 代码中。

6,04在安全方面有什么用,还有没有其他这样的组合,请解释一下。

(4, ID) 表示 link 到 id = ID 的现有记录,这将向现有记录添加关系。

(6, 0, [IDs]) 表示替换 linked ID 列表。首先,它将 unlink/delete 现有 ID 与该记录,然后 link 现有记录与 ID 列表中的每个 ID。

对于删除现有的id和link的id,会删除两个对象之间的关系,但不会删除目标对象本身(6, 0, [IDs])

更多详情,visit here.

终于在ORM写法中找到了答案

  • 对于 many2many 字段,需要一个元组列表。 这是接受的元组列表,具有相应的语义 ::

             (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)
    

示例: [(6, 0, [8, 5, 6, 4])] 将 many2many 设置为 ids [8, 5, 6, 4]

  • 对于一个 one2many 字段,预计会有一些元组。 这是接受的元组列表,具有相应的语义 ::

             (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)
    

    示例: [(0, 0, {'field_name':field_value_record1, ...}), (0, 0, {'field_name':field_value_record2, ...})]

  • 对于many2one字段,只需使用目标记录的ID,它必须已经存在,或者False删除link.

  • 对于参考字段,使用包含模型名称、逗号和目标对象 ID 的字符串(示例:'product.product, 5'

选项的完整列表在 documentation for the osv class.

(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)