# How to create in XML records with circular reference

**URL:** https://discuss.tryton.org/t/how-to-create-in-xml-records-with-circular-reference/5022
**Category:** Developer
**Created:** [February 16, 2022, 5:20pm UTC](https://discuss.tryton.org/t/how-to-create-in-xml-records-with-circular-reference/5022 "2022-02-16T17:20:37Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [February 16, 2022, 5:20pm UTC](https://discuss.tryton.org/t/how-to-create-in-xml-records-with-circular-reference/5022/1 "2022-02-16T17:20:37Z")

</div>

Some data model design may contain circular reference.  
For example in the module [`party_relationship`](https://docs.tryton.org/projects/modules-party-relationship/), the relation type can have a reverse relation that point to itself or to another relation type with a reverse relation to the initial relation type.

To create such record via XML data, you need to update already created record inside the same module. This is normally forbidden because the `id` of a `<record/>` must be unique. The way to get around this constraint, is to use for the second definition the `id` prefixed by the module name.  
Here is some examples:

```auto
<record model="party.relation.type" id="relation_type_child">
    <field name="name">Child</field>
</record>
<record model="party.relation.type" id="relation_type_parent">
    <field name="name">Parent</field>
    <field name="reverse" ref="relation_type_child"/>
</record>
<record model="party.relation.type" id="my_module.relation_type_child">
    <field name="reverse" ref="relation_type_parent"/>
</record>

```

```auto
<record model="party.relation.type" id="relation_type_sibling">
    <field name="name">Sibling</field>
</record>
<record model="party.relation.type" id="my_module.relation_type_sibling">
    <field name="reverse" ref="relation_type_sibling"/>
</record>

```
