Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

printing customer address Line1 and line2 etc on sales order #8977

Open
mabroens opened this issue Jan 28, 2025 · 1 comment
Open

printing customer address Line1 and line2 etc on sales order #8977

mabroens opened this issue Jan 28, 2025 · 1 comment
Labels
documentation question This is a question report Report/Label generation

Comments

@mabroens
Copy link

Body of the issue

Hi,

in my report i have:

{% block page_content %}
	<div class="customer-info">
        <div>
            <div>{{ customer.name }}</div>
            <div>attn.: {{ order.contact.name }}</div>
            <div>{{ order.contact.email }}</div>
            {% if customer.address %} {{ customer.address}} {% else %} <div>{{ customer.address }}</div> {% endif %}
            {% if customer.PostalCode %} {{ customer.PostalCode }} {% else %} <div><!-- [Zip] --></div> {% endif %}
            {% if customer.City %} {{ customer.City }} {% else %} <div><!-- [Place] --></div> {% endif %}
            {% if customer.Country %} {{ customer.Country }} {% else %} <div><!-- [Country] --></div> {% endif %}
			<br>
			<br>
        </div>
    </div>
	

but the lines are not working as i would like them to i.e. i would like to be able to print the individual lines from the adress fields like PostalCode, City Line1 Line2 etc..

coudl you instruct me how i can add these to the template?

br Martijn

@mabroens mabroens added documentation triage:not-checked Item was not checked by the core team labels Jan 28, 2025
@SchrodingersGat SchrodingersGat added question This is a question report Report/Label generation and removed triage:not-checked Item was not checked by the core team labels Jan 29, 2025
@SchrodingersGat
Copy link
Member

The "customer" is a Company instance which does not have the fields you are looking for (country / city / etc). They are linked to the Address model

A customer can have multiple addresses specifed - but only one as the "primary" address.

You can access this with the following:

{% if customer.primary_address %}
Line 1: {{ customer.primary_address.line_1 }}
Line 2: {{ customer.primary_address.line_2 }}
{% endif %}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation question This is a question report Report/Label generation
Projects
None yet
Development

No branches or pull requests

2 participants