Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
12945 Zobrazení

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

Avatar
Zrušit
Nejlepší odpověď

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...

Avatar
Zrušit
Nejlepší odpověď
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>
Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
1
dub 22
18364
0
led 22
1900
3
pro 23
3930
0
pro 22
1691
0
čvc 20
3059