ROOM64 / KNOWLEDGE / ERPNEXT

Address Template

An Address Template controls how ERPNext formats an Address when it appears on transactions, print formats, previews, and communications. Country-specific templates let each region

อ่านต้นฉบับที่ ERPNext Official Docs ↗
เอกสารอ้างอิงภาษาอังกฤษเนื้อหาจากเอกสาร ERPNext คงรายละเอียดและโค้ดตามต้นฉบับ · ต้นฉบับอัปเดต 2026-07-23 ชื่อเมนูและ DocType ที่ใช้ได้ขึ้นอยู่กับเวอร์ชันและรุ่นที่ทีมใช้งาน

Selling · งานขาย · Address Template

สารบัญในหน้านี้

An Address Template controls how ERPNext formats an Address when it appears on transactions, print formats, previews, and communications. Country-specific templates let each region use the expected order, labels, and optional fields.

ERPNext selects a template from the Address's Country. If no country-specific template exists, it uses the template marked as default.

United States Address Template editor with Jinja fields and default status.

Before you begin

You need:

  • System Manager or equivalent permission;
  • the Country for which the format applies;
  • a sample Address containing all relevant fields;
  • basic HTML and Jinja template knowledge; and
  • a test transaction or print format on which to verify the result.

Copy the existing template text before making a substantial change. A syntax error can affect every document that renders an Address for that country.

Create an Address Template

  1. Open CRM > Address Template .
  2. Select Add Address Template .
  3. Choose the Country .
  4. Enter the Jinja and HTML template.
  5. Enable Is Default only when this should be the fallback for countries without a specific template.
  6. Save the Address Template.

Normally, create one template per Country. Keep only one appropriate default fallback.

Edit an existing template

  1. Open the template for the required Country.
  2. Copy the current template for rollback.
  3. Make the smallest required change.
  4. Save.
  5. Open a representative Customer or Supplier Address and verify the rendered result.
  6. Test at least one Quotation , Sales Invoice , or relevant print preview.

Formatted billing and shipping Addresses shown on a Customer.

Do not treat a successful save as proof that the output is correct. Verify line breaks, missing values, labels, punctuation, and narrow print layouts.

Important fields and concepts

Field or conceptWhat it controls
CountryDetermines which Addresses use this template
Is DefaultMakes the template the fallback when no country-specific template exists
TemplateJinja and HTML used to render the formatted Address
address_line1First street or building line
address_line2Optional second address line
cityCity or town
countyCounty or equivalent regional division
stateState, province, or region
pincodePostal, ZIP, or PIN code
countryCountry name
Contact fieldsOptional phone, fax, and email values available to the template
Custom FieldsAdditional Address fields available by their fieldnames

Fieldnames are case-sensitive. Use the fieldname shown in Customize Form or DocType metadata, not the field label visible to users.

Write safe Jinja

Wrap optional values in conditions so empty fields do not produce blank labels or punctuation:

{{ address_line1 }}<br>
{% if address_line2 %}{{ address_line2 }}<br>{% endif %}
{{ city }}{% if state %}, {{ state }}{% endif %} {{ pincode }}<br>
{{ country }}

Use <br> for deliberate address line breaks. Keep complex business logic out of the template; store normalized data in the Address instead.

The template engine exposes standard and Custom Fields from Address. See Customize Form before referencing a custom field.

Country-specific and default behaviour

For a United States Address, a template may render City, State, and ZIP on one line and include County only when required. Another Country may place the postal code before the city.

ERPNext determines the template at render time using the Country on the Address. Therefore:

  • correct the Country when the wrong template appears;
  • create a country-specific template for a real regional difference;
  • use the default template as a safe general fallback; and
  • avoid marking several conflicting templates as default.

Address Templates affect Customers , Suppliers , Companies , Warehouses, Contacts, and transactions such as Delivery Notes wherever formatted Addresses are rendered.

Save and next steps

Address Template is saved rather than submitted. After saving:

  • check several complete and incomplete Addresses;
  • verify billing and shipping results;
  • preview a Sales Order and a Purchase Invoice ;
  • test any relevant custom print format; and
  • document custom field dependencies for future administrators.

Troubleshooting

ProblemWhat to check
The wrong format appearsVerify the Address Country and country-specific template
No country-specific template existsERPNext should use the template marked default
Blank labels or punctuation appearWrap the entire optional line or label in a Jinja condition
A field never appearsConfirm its exact fieldname and that the Address contains a value
Save succeeds but print output breaksCheck HTML structure, Jinja blocks, and the print format's available width
A custom field causes an errorConfirm the field exists in every target environment or guard it appropriately

Frequently asked questions

Can I use Custom Fields?

Yes. Address Custom Fields are available to the template by fieldname.

Should every Country have a template?

No. Create country-specific templates only where formatting differs; the default handles the rest.

Can the template change field labels such as PIN to ZIP?

Yes. Write the desired label directly in the country-specific template.

Do template changes update submitted documents?

They can change newly rendered address output, depending on how a document or print format stores or fetches the address. Test the exact document type before relying on historical behaviour.

Can CSS be used?

Keep styling restrained and compatible with the target print format. Prefer semantic HTML and simple line breaks for addresses.

เนื้อหาเอกสารอ้างอิงและภาพประกอบมาจาก ERPNext / Frappe Official Docs · บทความแนะนำภาษาไทยเรียบเรียงโดย Room64 · เว็บไซต์นี้เป็นคู่มือประกอบการใช้งานโดย Room64 · เอกสารทางการ ↗

มีงานที่อยากให้ Software, AI หรือ Automation ช่วยอยู่ไหม?

เล่า workflow หรือปัญหาที่ทีมกำลังเจอ เราช่วยดูได้ว่าควรใช้ระบบสำเร็จรูป เชื่อมเครื่องมือเดิม หรือพัฒนาเพิ่มเฉพาะส่วนไหน

คุยกับเราทาง LINEhello@room64.net