Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
2 Ответы
13362 Представления

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
2437
3
дек. 23
4883
0
дек. 22
2352
0
июл. 20
3602