Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
2 Antworten
13381 Ansichten

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
Verwerfen
Beste Antwort

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
Verwerfen
Beste Antwort
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
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
1
Apr. 22
18364
0
Jan. 22
2448
3
Dez. 23
4895
0
Dez. 22
2355
0
Juli 20
3605