# Howto import an invoice for a party with several addresses?

**URL:** https://discuss.tryton.org/t/howto-import-an-invoice-for-a-party-with-several-addresses/339
**Category:** User
**Created:** [April 11, 2017, 11:27am UTC](https://discuss.tryton.org/t/howto-import-an-invoice-for-a-party-with-several-addresses/339 "2017-04-11T11:27:33Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Jani-Matti](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/j/bc8723/32.png) [@Jani-Matti](https://discuss.tryton.org/u/Jani-Matti)
#### Post date: [April 11, 2017, 11:27am UTC](https://discuss.tryton.org/t/howto-import-an-invoice-for-a-party-with-several-addresses/339/1 "2017-04-11T11:27:33Z")

</div>

Which address ID should one use when importing an invoice for a party with multiple addresses?

I’ve tried using the ID of the desired address, as well as the Full Address text string, but those both lead to a “Relation not found: in party.address.” error. If I use the ID of the party in question, I get a “Too many relations found: in party.address” error.

We have both an invoicing and a delivery address for all of our clients, which I would think is a fairly normal situation.

---

<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: [April 11, 2017, 1:00pm UTC](https://discuss.tryton.org/t/howto-import-an-invoice-for-a-party-with-several-addresses/339/2 "2017-04-11T13:00:22Z")

</div>

CSV import is very complex task and requires internal knowledge of the database and model design. For example, the relation of Many2One are searched by rec\_name so the value encoded in the CSV must be sure to return a single record.  
So this makes the CSV importation useful only for very simple case. And other case, we recommend to write a script using [proteus](http://hg.tryton.org/proteus).

---

<div class="post-metadata">

### Author: ![Jani-Matti](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/j/bc8723/32.png) [@Jani-Matti](https://discuss.tryton.org/u/Jani-Matti)
#### Post date: [April 11, 2017, 1:59pm UTC](https://discuss.tryton.org/t/howto-import-an-invoice-for-a-party-with-several-addresses/339/3 "2017-04-11T13:59:36Z")

</div>

But is there a particular reason why the invoice import won’t accept the actual Address record ID as input? You already have to feed it the Party Code to associate the invoice with a party in general.

At the very least, if the party has only one Invoice address, couldn’t that be used as the default?

Seems more like a bug.

---

<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: [April 11, 2017, 9:17pm UTC](https://discuss.tryton.org/t/howto-import-an-invoice-for-a-party-with-several-addresses/339/4 "2017-04-11T21:17:24Z")

</div>

> [@Jani-Matti](#):
>
> But is there a particular reason why the invoice import won’t accept the actual Address record ID as input?

Yes, CVS import does not work with ID because it is internal to the system so ID should not be exposed to the outside.

> [@Jani-Matti](#):
>
> At the very least, if the party has only one Invoice address, couldn’t that be used as the default?

CVS import is just doing what it is told to do. It will never randomly trigger any events.

You really seem to look for scripting the UI instead of importing data. And this is exactly the goal of proteus.

---

<div class="post-metadata">

### Author: ![Jani-Matti](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/j/bc8723/32.png) [@Jani-Matti](https://discuss.tryton.org/u/Jani-Matti)
#### Post date: [April 11, 2017, 11:05pm UTC](https://discuss.tryton.org/t/howto-import-an-invoice-for-a-party-with-several-addresses/339/5 "2017-04-11T23:05:57Z")

</div>

> [@ced](#):
>
> Yes, CSV import does not work with ID because it is internal to the system so ID should not be exposed to the outside.

Yet I can export the ID of almost any record.

If CSV import is just meant to be a tool to import raw data, wouldn’t it be rather more sensible if one could (if one wanted to) use internal IDs to precisely and explicitly import just the data one wants to import? Naturally this would also require code to handle updating records through CSV imports, rather than just creating new ones.

Besides, the invoice import seems a bit weird nevertheless. The CSV import dialog asks for an Invoice Address field, but will only actually accept a Party Code. That doesn’t quite seem right.

> [@ced](#):
>
> CSV import is just doing what it is told to do. It will never randomly trigger any events.

This I wholeheartedly agree with. This is just the way it should be.

> [@ced](#):
>
> You really seem to look for scripting the UI instead of importing data. And this is exactly the goal of proteus.

Yes. Scripting, or rather, a set of full fledged Tryton modules is definitely our endgame. However, due to, well let’s call them ‘various business reasons’ that goal won’t be happening in a day, or even a year. Not even if said Tryton modules already existed.

So for now, we’ll be stuck with getting the data we need from various sources, and putting it together in, well, Excel unfortunately. Lucky for us, we only need import it to Tryton 1-4 times a year for invoicing. Thus, a CSV import is actually a fairly functional workflow for now.

Also, when we do import the invoices, we import thousands of them at once. So any non-bulk solution would not work.
