ERPNext Foundation ERPNext Cloud User Manual Blog Discuss Frappé* Donate

How to get Company Address in HTML Template?


#1

Hi there,

i’m trying to get company address from html template, any hint?

Thx


#2

Anyone has the same prob?


#3

Do you mean this?


please elaborate.


#4

@Mohammed_Redha Yup …it is changed in version 8 …now the field is address_html and display addresses from Address DocType …it seems kind of complicated to retrieve Company address …

i’ve tried to use:

But getting an error:

("'dict object' has no attribute 'geo'",)


#5

Can someone help on this? It’s really frustrating … :frowning::disappointed_relieved:


#6

Hi @JoEz,

I know this is far from pretty but it worked for me:

{% set links = frappe.get_all('Dynamic Link', filters={'link_doctype': 'Company', 'link_name': doc.company, 'parenttype': 'Address'}, fields=['parent']) %}
{% if links %}
{% set address = frappe.get_doc("Address", links[0].parent) %}
{% endif %} 

Playing with the filters helps if there are multiple addresses. Hope it helps… :wink:


#7

{% set links = frappe.get_all(‘Dynamic Link’, filters={‘link_doctype’: ‘Company’, ‘link_name’: doc.company, ‘parenttype’: ‘Address’}, fields=[‘parent’]) %}
{% if links %}
{{frappe.db.get_value(“Address”, links[0].parent, “address_line1”)}}
{% endif %}

its working


#8

{{ doc. address_display or ‘’ }}