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?
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).