Address ISO-2 Code

European Address Standard Structure is

John Doe
Samplestreet 1
DE-83838 Sampletown

How do I get the country code instead of the country name in the address template?

{{ address_line1 }}
{% if address_line2 %}{{ address_line2 }}
{% endif -%}
{{ country }}-{% if pincode %}{{ pincode }} {% endif -%}{{city }}

try replacing {{ country }} by {{ frappe.db.get_value("Country", country, "code") if country else ""}}


WOOOOOOW!!! That was probably the quickest and perfectly working solution I have ever received in a forum!!! Thanks a lot! I also learned a bit more about how erpnext works.