2014-09-24 53 views
4

我正在使用OpenERP 7.0。 下面的代碼是來自文件addons/project/security/project_security.xmlOpenERP/Odoo模型關係XML語法

請解釋我在哪裏數字4,6和0是從哪裏? 在文檔中哪個地方可以諮詢一下?

<record id="group_project_user" model="res.groups"> 
    <field name="name">User</field> 
    <field name="category_id" ref="base.module_category_project_management"/> 
</record> 

<record id="group_project_manager" model="res.groups"> 
    <field name="name">Manager</field> 
    <field name="category_id" ref="base.module_category_project_management"/> 
    <field name="implied_ids" eval="[(4, ref('group_project_user'))]"/> 
    <field name="users" eval="[(4, ref('base.user_root'))]"/> 
</record> 

<record model="ir.ui.menu" id="base.menu_definitions"> 
    <field name="groups_id" eval="[(6,0,[ref('group_project_manager')])]"/> 
</record> 

回答

11

對於many2many field,預計有一個元組列表。 這裏是被接受,與相應的語義元組的列表:

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

Example: 
[(6, 0, [8, 5, 6, 4])] sets the many2many to 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) 

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

我希望這會清除你的疑慮

感謝和問候

+0

非常感謝您亞辛。你的解釋非常清楚。如果你讓我知道你怎麼知道這件事,我會更加感謝你。我希望有官方文件可以自己學習這樣的東西。無論如何,你的答案已經幫助了我很多。 :D – 2014-09-24 23:51:10

+2

按照ORM模型和方法檢查Odoo.com上的文檔。幻數是奇怪的事情,但保存代碼。 – 2014-09-25 02:25:24

+2

感謝艾德里安的指導。我在這裏找到它[https://doc.odoo.com/6.0/developer/2_5_Objects_Fields_Methods/methods/](https://doc.odoo.com/6.0/developer/2_5_Objects_Fields_Methods/methods/) – 2014-09-25 02:57:26