Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
13390 มุมมอง

Hi folks, I'm trying to create some db records using xml and can't find any examples on how to create many2many relations. I want to do something like this:

<record model="product.product" id="product_1"> <field name="name">Product 1</field> <field name="product_component_ids" ref="component_id"/> </record>

Thanks! iain

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

for m2m value in xml use syntax:


<field name="your_field" eval="[(6, 0, [ ref('module_name.external_id_1'), ref('module_name.external_id_2')])]"/>

or 

<field name="your_field" eval="[(0, 0, [ {'field_1':value_1, 'field_2':value_2}] )]"/>

hoep it helps...

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด
tks Bole
eg:
<record model="product.component" id="component_1"> <field name="name">Component 1</field> </record> <record model="product.component" id="component_2"> <field name="name">Component 2</field> </record> <record model="product.product" id="product_1"> <field name="name">Product 1</field> <field name="product_component_ids" eval="[(6, 0, [ ref('component_1'), ref('component_2')])]"/> </record>
อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
เม.ย. 22
18364
0
ม.ค. 22
2454
3
ธ.ค. 23
4902
0
ธ.ค. 22
2358
0
ก.ค. 20
3615