This question has been flagged
3 Replies
6270 Views

How to import a one2many field in odoo12 Community Version

Please Help...

Thanks in Advance...

Avatar
Discard
Best Answer

Hi,

Your question was not clear if it is about CSV import or XML so I decided to write out both.
If it is in CSV you should first import the parent model records. After you've imported those you can import the records from the child table. Your child table should have a many2one to point to the one2many field of the parent table. In this case you import the parent records, export them (to get out the ID's) and match those ID's as a field in the CSV to match the child records to the parent with this id.

If it is in XML I usually import them the other way around. First the parent record and then link the childs to the parent with the many2one field. An example:

<?xml version="1.0" ?>
<odoo>
    <record id="parent_record" model="parent.model">
        <field name="name">Some name/title</field>
    </record>


    <record id="child_record" model="child.model">
        <field name="name">Some name/title</field>
        <field name="many2one_to_parent" ref="parent_record"/>
    </record>
</odoo>

Alternatively one2many links should also work if they're defined in a many2many like definition:

<field name="one2many_to_childs" eval="[(6, 0, [ref('child_record'), ref('child_record_2')])]"/>

Regards,

Yenthe

Avatar
Discard
Best Answer

You need to provide more details

Avatar
Discard
Author

Just to importa a file...If the file contains fields of one2many field..

How to import it..

Thats all...