Print Delivery Address on Invoice

Tryton Version 5.6.
I have a party with an invoice address and several delivery addresses.
In the sale module, I choose the party, the invoice address and the delivery address.

Is the delivery address available in the “invoice” report, so I can print it on the invoice?
I tried “invoice.delivery_address.full_address”, but it’s throwing an error.

More general question: is it possible to see which variables are available in a specific report?

Thank you for any hint.

It is possible to create an invoice which is made up from lines from several different sales orders, and therefore it may have several different delivery addresses.

However, for the simple case where all the lines come from the same sales order then you should be able to find the delivery address with something like:

invoice.lines[0].origin.sale.shipment_address.full_address

Note: This assumes the first line on the invoice is from the sale, and I haven’t tried this out myself, but hopefully it will get you close.

I’m not sure if there is an easy way, it depends on which modules you have installed. One way is to look at the fields that are defined for each of the models in the source code, this is where the answer above came from:

You can see all fields of a model in Administration menu / Models

3 Likes

Yes, much easier than looking through the source :+1:

Dave, thanks a lot for the clarification, it is true that there could be more than one delivery addresses.
invoice.lines[0].origin.sale.shipment_address.full_address works perfectly, and is all I need at the moment.

Sergyo, thank you for the hint. Now I begin to understand how the internals work together. Will continue learning…

Summary:
To print the delivery address on the invoice, if you are very sure that there is only ONE delivery address per invoice, the following code example works:

<if test="invoice.lines[0].origin">
Geliefert an (Delivered to):
<for each="line in invoice.lines[0].origin.sale.shipment_address.full_address.split('\n')">
<line>
</for>
</if>
1 Like

You may loop on the invoice.sales and render each delivery address but you may have duplicated addresses. In this case you will need some code to make them unique.

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