# Import data with One2Many with Proteus

**URL:** <https://discuss.tryton.org/t/import-data-with-one2many-with-proteus/3098>\
**Category:** Developer\
**Created:** [August 5, 2020, 10:20am UTC](https://discuss.tryton.org/t/import-data-with-one2many-with-proteus/3098 "2020-08-05T10:20:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![2cadz](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/2cadz/32/130_2.png) [@2cadz](https://discuss.tryton.org/u/2cadz)\
**Post date:** [August 5, 2020, 10:20am UTC](https://discuss.tryton.org/t/import-data-with-one2many-with-proteus/3098/1 "2020-08-05T10:20:34Z")

</div>

Hi,

I have the following code:

```auto
data = {
     'name': 'test',
     'code': '0123',
     'addresses': [{'city': 'Aix en provence', 'zip': '13090'}],
     },
Party = Model.get('party.party')
party = Party(**data)
party.save()

```

it works, but in the `addresses` field i have 2 addresses, the first one being empty, is there a way (syntax) to only have the information i put in the` addresses` key of the dictionary?

Regards.

---

<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:** [August 5, 2020, 2:12pm UTC](https://discuss.tryton.org/t/import-data-with-one2many-with-proteus/3098/2 "2020-08-05T14:12:12Z")

</div>

This is because proteus set default values first (and party has a default\_addresses which return an empty record). Then it applies the values passed. The xxx2Many values passed extend the exiting list.  
An option is to pass `_default=False` which will prevent to set the default value (but for all fields). Or you can just pop the first address before saving: `party.addresses.pop(0)`.

---

<div class="post-metadata">

**Author:** ![system](https://discuss-cdn.tryton.org/uploads/default/original/1X/c6f8ec0a40525cdcd50058c734283450a4b3d38b.png) [@system](https://discuss.tryton.org/u/system)\
**Post date:** [September 4, 2020, 2:12pm UTC](https://discuss.tryton.org/t/import-data-with-one2many-with-proteus/3098/3 "2020-09-04T14:12:16Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
