From f0961de744b64650bc517d5d854d870819c0c803 Mon Sep 17 00:00:00 2001 From: kurogeek Date: Mon, 14 Sep 2026 09:42:27 +0000 Subject: [PATCH] feat: customer contact column on Default Standard Sales Invoice - Split the Customer block into two columns: name / address / tax id on the left, contact person with phone, mobile and email on the right (only when the invoice has a contact person; phone read from Contact) - Thailand Address Template: drop the blank line between the address and the phone / fax / email lines --- default_thai_company/fixtures/address_template.json | 4 ++-- default_thai_company/fixtures/print_format.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/default_thai_company/fixtures/address_template.json b/default_thai_company/fixtures/address_template.json index fc0a8eb..02a47e2 100644 --- a/default_thai_company/fixtures/address_template.json +++ b/default_thai_company/fixtures/address_template.json @@ -6,6 +6,6 @@ "is_default": 1, "modified": "2026-09-09 17:23:33.559202", "name": "Thailand", - "template": "{{ address_line1 }}{% if address_line2 %} {{ address_line2 }}{% endif %}
\n{% if county %}{{ county }} {% endif -%}{{ city }}{% if state %} {{ state }}{% endif -%}{% if pincode %} {{ pincode }}{% endif -%}{% if country != \"Thailand\" %} {{ country }}{% endif %}
\n{% if phone or fax or email_id %}
{% endif -%}\n{% if phone %}{{ _(\"Phone\") }}: {{ phone }}
{% endif -%}\n{% if fax %}{{ _(\"Fax\") }}: {{ fax }}
{% endif -%}\n{% if email_id %}{{ _(\"Email\") }}: {{ email_id }}
{% endif -%}\n" + "template": "{{ address_line1 }}{% if address_line2 %} {{ address_line2 }}{% endif %}
\n{% if county %}{{ county }} {% endif -%}{{ city }}{% if state %} {{ state }}{% endif -%}{% if pincode %} {{ pincode }}{% endif -%}{% if country != \"Thailand\" %} {{ country }}{% endif %}
\n{% if phone %}{{ _(\"Phone\") }}: {{ phone }}
{% endif -%}\n{% if fax %}{{ _(\"Fax\") }}: {{ fax }}
{% endif -%}\n{% if email_id %}{{ _(\"Email\") }}: {{ email_id }}
{% endif -%}\n" } -] +] \ No newline at end of file diff --git a/default_thai_company/fixtures/print_format.json b/default_thai_company/fixtures/print_format.json index 4142d06..949d20e 100644 --- a/default_thai_company/fixtures/print_format.json +++ b/default_thai_company/fixtures/print_format.json @@ -12,7 +12,7 @@ "font": null, "font_size": 14, "format_data": null, - "html": "{%- from \"templates/print_formats/standard_macros.html\" import add_header, render_field with context -%}\n{%- set bank_account = get_company_bank_account(doc.company) -%}\n{#- ERPNext hides taxes marked \"Is this Tax included in Basic Rate?\" unless Accounts Settings\n enables \"Show Inclusive Tax in Print\"; always show them here so the tax line and\n \"Total (Without Tax)\" appear on invoices with inclusive tax. -#}\n{%- if doc.get(\"taxes\", {\"included_in_print_rate\": 1}) -%}\n\t{%- set ignored = doc.flags.update({\"show_inclusive_tax_in_print\": 1}) -%}\n{%- endif -%}\n{#- Standard layout prints every non-empty field; drop the ones this invoice does not need.\n posting_date / due_date are printed in the heading, customer fields in the Customer section,\n in_words in the left column of the Totals section. -#}\n{%- set hidden_fields = [\n\t\"total_qty\", \"update_billed_amount_in_delivery_note\", \"amount_eligible_for_commission\", \"company_tax_id\",\n\t\"posting_date\", \"due_date\",\n\t\"customer_name\", \"address_display\", \"contact_display\", \"contact_mobile\", \"tax_id\",\n\t\"in_words\",\n] -%}\n{#- add_header renders this string via frappe.render_template with {\"doc\": doc}, so it is kept\n unrendered with {% raw %}. Same markup as the stock heading plus a right-aligned date block. -#}\n{%- set heading_template -%}\n{% raw %}\n
\n\t\n\t
\n\t\t
{{ doc.get_formatted(\"posting_date\") }}
\n\t\t{%- if doc.due_date %}\n\t\t
{{ doc.get_formatted(\"due_date\") }}
\n\t\t{%- endif %}\n\t
\n\t

\n\t\t
{{ _(doc.select_print_heading) or (_(doc.print_heading) if doc.print_heading != None else _(doc.doctype)) }}
\n\t\t{{ _(doc.sub_heading) if doc.sub_heading != None else _(doc.name) }}\n\t

\n\t
\n
\n{% endraw %}\n{%- endset -%}\n{#- Standard layout prints every non-empty child column; keep the item table to the essentials -#}\n{%- set item_columns = [\n\t{\"fieldname\": \"item_code\"},\n\t{\"fieldname\": \"description\"},\n\t{\"fieldname\": \"qty\"},\n\t{\"fieldname\": \"rate\"},\n\t{\"fieldname\": \"amount\"},\n] -%}\n\n{%- macro render_fields(fields, no_of_cols) -%}\n\t{%- for df in fields -%}\n\t\t{%- if df.fieldname not in hidden_fields -%}\n\t\t\t{%- if df.fieldname == \"items\" -%}\n\t\t\t\t{%- set df = df.as_dict() -%}\n\t\t\t\t{%- set ignored = df.update({\"visible_columns\": item_columns}) -%}\n\t\t\t{%- endif -%}\n\t\t\t{{ render_field(df, doc, no_of_cols) }}\n\t\t{%- endif -%}\n\t{%- endfor -%}\n{%- endmacro -%}\n\n{% for page in layout %}\n
\n\t
\n\t\t{{ add_header(loop.index, layout|len, doc, letter_head, no_letterhead, footer, print_settings, heading_template) }}\n\t
\n\n\t{% if loop.first %}\n\t
\n\t\t
\n\t\t\t

{{ _(\"Customer\") }}

\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t{% if doc.address_display %}\n\t\t\t\t\t\n\t\t\t\t\t{% endif %}\n\t\t\t\t\t{% if doc.contact_display or doc.contact_mobile %}\n\t\t\t\t\t\n\t\t\t\t\t{% endif %}\n\t\t\t\t\t{% if doc.tax_id %}\n\t\t\t\t\t\n\t\t\t\t\t{% endif %}\n\t\t\t\t\n\t\t\t
{{ _(doc.meta.get_label(\"customer_name\")) }}{{ doc.customer_name or doc.customer }}
{{ _(doc.meta.get_label(\"address_display\")) }}{{ doc.address_display }}
{{ _(doc.meta.get_label(\"contact_display\")) }}{{ [doc.contact_display, doc.contact_mobile] | select | join(\", \") }}
{{ _(doc.meta.get_label(\"tax_id\")) }}{{ doc.tax_id }}
\n\t\t
\n\t
\n\t{% endif %}\n\n\t{% for section in page %}\n\t
\n\t\t{%- if doc.print_line_breaks and loop.index != 1 -%}
{%- endif -%}\n\t\t{%- if doc.print_section_headings and section.label and section.has_data -%}\n\t\t

{{ _(section.label) }}

\n\t\t{%- endif -%}\n\t\t{%- set no_of_cols = section.columns|len -%}\n\t\t{%- set section_fieldnames = [] -%}\n\t\t{%- for column in section.columns -%}\n\t\t\t{%- for df in column.fields -%}{%- set ignored = section_fieldnames.append(df.fieldname) -%}{%- endfor -%}\n\t\t{%- endfor -%}\n\t\t{%- if \"total\" in section_fieldnames -%}\n\t\t{#- \"total\" sits in a 3-column section, so its label/value grid does not line up with the\n\t\t Taxes and Totals sections below it. Render it in the same right-half 6/6 grid they use. -#}\n\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t{%- for column in section.columns -%}{{ render_fields(column.fields, 1) }}{%- endfor -%}\n\t\t\t\t\t
\n\t\t\t\t
\n\t\t\t
\n\t\t{%- else -%}\n\t\t{% for column in section.columns %}\n\t\t\t
\n\t\t\t{%- if loop.first and \"in_words\" in section_fieldnames and doc.in_words -%}\n\t\t\t{#- The Totals section's left column is empty in print; put the amount in words there,\n\t\t\t on the same line as Grand Total, instead of under Rounded Total on the right. -#}\n\t\t\t\t
\n\t\t\t\t\t
{{ doc.in_words }}
\n\t\t\t\t
\n\t\t\t{%- endif -%}\n\t\t\t{{ render_fields(column.fields, no_of_cols) }}\n\t\t\t
\n\t\t{% endfor %}\n\t\t{%- endif -%}\n\t
\n\t{% endfor %}\n\n\t{% if loop.last and bank_account %}\n\t
\n\t\t{%- if doc.print_line_breaks -%}
{%- endif -%}\n\t\t
\n\t\t\t

{{ _(\"Bank Account Details\") }}

\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t{% if bank_account.bank_account_no %}\n\t\t\t\t\t\n\t\t\t\t\t{% endif %}\n\t\t\t\t\t{% if bank_account.iban %}\n\t\t\t\t\t\n\t\t\t\t\t{% endif %}\n\t\t\t\t\t{% if bank_account.branch_code %}\n\t\t\t\t\t\n\t\t\t\t\t{% endif %}\n\t\t\t\t\t{% if bank_account.swift_number %}\n\t\t\t\t\t\n\t\t\t\t\t{% endif %}\n\t\t\t\t\n\t\t\t\n\t\t
\n\t
\n\t{% endif %}\n\n\t{% if loop.last %}\n\t
\n\t\t
\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t
\n\t\t\t\t\t\t\t
{{ _(\"On behalf of\") }} {{ doc.customer_name or doc.customer }}
\n\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t
{{ _(\"Receiver\") }}{{ _(\"Date\") }}
\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t
{{ _(\"On behalf of\") }} {{ doc.company }}
\n\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t
{{ _(\"Issuer\") }}{{ _(\"Date\") }}
\n\t\t\t\t\t\t
\n\t\t
\n\t
\n\t{% endif %}\n\n\t
\n\t\t{% if not no_letterhead and footer %}\n\t\t
\n\t\t\t{{ footer }}\n\t\t
\n\t\t{% endif %}\n\t\t{% if print_settings.repeat_header_footer %}\n\t\t\t

\n\t\t\t\t{{ _(\"Page {0} of {1}\").format('', '') }}\n\t\t\t

\n\t\t{% endif %}\n\t
\n
\n{% endfor %}\n\n\n\n\n\n", + "html": "{%- from \"templates/print_formats/standard_macros.html\" import add_header, render_field with context -%}\n{%- set bank_account = get_company_bank_account(doc.company) -%}\n{#- ERPNext hides taxes marked \"Is this Tax included in Basic Rate?\" unless Accounts Settings\n enables \"Show Inclusive Tax in Print\"; always show them here so the tax line and\n \"Total (Without Tax)\" appear on invoices with inclusive tax. -#}\n{%- if doc.get(\"taxes\", {\"included_in_print_rate\": 1}) -%}\n\t{%- set ignored = doc.flags.update({\"show_inclusive_tax_in_print\": 1}) -%}\n{%- endif -%}\n{#- Standard layout prints every non-empty field; drop the ones this invoice does not need.\n posting_date / due_date are printed in the heading, customer fields in the Customer section,\n in_words in the left column of the Totals section. -#}\n{%- set hidden_fields = [\n\t\"total_qty\", \"update_billed_amount_in_delivery_note\", \"amount_eligible_for_commission\", \"company_tax_id\",\n\t\"posting_date\", \"due_date\",\n\t\"customer_name\", \"address_display\", \"contact_display\", \"contact_mobile\", \"contact_email\", \"tax_id\",\n\t\"in_words\",\n] -%}\n{#- add_header renders this string via frappe.render_template with {\"doc\": doc}, so it is kept\n unrendered with {% raw %}. Same markup as the stock heading plus a right-aligned date block. -#}\n{%- set heading_template -%}\n{% raw %}\n
\n\t\n\t
\n\t\t
{{ doc.get_formatted(\"posting_date\") }}
\n\t\t{%- if doc.due_date %}\n\t\t
{{ doc.get_formatted(\"due_date\") }}
\n\t\t{%- endif %}\n\t
\n\t

\n\t\t
{{ _(doc.select_print_heading) or (_(doc.print_heading) if doc.print_heading != None else _(doc.doctype)) }}
\n\t\t{{ _(doc.sub_heading) if doc.sub_heading != None else _(doc.name) }}\n\t

\n\t
\n
\n{% endraw %}\n{%- endset -%}\n{#- Standard layout prints every non-empty child column; keep the item table to the essentials -#}\n{%- set item_columns = [\n\t{\"fieldname\": \"item_code\"},\n\t{\"fieldname\": \"description\"},\n\t{\"fieldname\": \"qty\"},\n\t{\"fieldname\": \"rate\"},\n\t{\"fieldname\": \"amount\"},\n] -%}\n\n{%- macro render_fields(fields, no_of_cols) -%}\n\t{%- for df in fields -%}\n\t\t{%- if df.fieldname not in hidden_fields -%}\n\t\t\t{%- if df.fieldname == \"items\" -%}\n\t\t\t\t{%- set df = df.as_dict() -%}\n\t\t\t\t{%- set ignored = df.update({\"visible_columns\": item_columns}) -%}\n\t\t\t{%- endif -%}\n\t\t\t{{ render_field(df, doc, no_of_cols) }}\n\t\t{%- endif -%}\n\t{%- endfor -%}\n{%- endmacro -%}\n\n{% for page in layout %}\n
\n\t
\n\t\t{{ add_header(loop.index, layout|len, doc, letter_head, no_letterhead, footer, print_settings, heading_template) }}\n\t
\n\n\t{% if loop.first %}\n\t
\n\t\t
\n\t\t\t

{{ _(\"Customer\") }}

\n\t\t\t\n\t\t
\n\t\t
\n\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t{% if doc.address_display %}\n\t\t\t\t\t\n\t\t\t\t\t{% endif %}\n\t\t\t\t\t{% if doc.tax_id %}\n\t\t\t\t\t\n\t\t\t\t\t{% endif %}\n\t\t\t\t\n\t\t\t
{{ _(doc.meta.get_label(\"customer_name\")) }}{{ doc.customer_name or doc.customer }}
{{ _(doc.meta.get_label(\"address_display\")) }}{{ doc.address_display }}
{{ _(doc.meta.get_label(\"tax_id\")) }}{{ doc.tax_id }}
\n\t\t
\n\t\t
\n\t\t\t{% if doc.contact_person %}\n\t\t\t{#- Sales Invoice carries the contact's mobile and email but not its phone; read that from the Contact. -#}\n\t\t\t{%- set contact_phone = frappe.db.get_value(\"Contact\", doc.contact_person, \"phone\") -%}\n\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t{% if contact_phone %}\n\t\t\t\t\t\n\t\t\t\t\t{% endif %}\n\t\t\t\t\t{% if doc.contact_mobile %}\n\t\t\t\t\t\n\t\t\t\t\t{% endif %}\n\t\t\t\t\t{% if doc.contact_email %}\n\t\t\t\t\t\n\t\t\t\t\t{% endif %}\n\t\t\t\t\n\t\t\t
{{ _(doc.meta.get_label(\"contact_person\")) }}{{ doc.contact_display or doc.contact_person }}
{{ _(frappe.get_meta(\"Contact\").get_label(\"phone\")) }}{{ contact_phone }}
{{ _(doc.meta.get_label(\"contact_mobile\")) }}{{ doc.contact_mobile }}
{{ _(doc.meta.get_label(\"contact_email\")) }}{{ doc.contact_email }}
\n\t\t\t{% endif %}\n\t\t
\n\t
\n\t{% endif %}\n\n\t{% for section in page %}\n\t
\n\t\t{%- if doc.print_line_breaks and loop.index != 1 -%}
{%- endif -%}\n\t\t{%- if doc.print_section_headings and section.label and section.has_data -%}\n\t\t

{{ _(section.label) }}

\n\t\t{%- endif -%}\n\t\t{%- set no_of_cols = section.columns|len -%}\n\t\t{%- set section_fieldnames = [] -%}\n\t\t{%- for column in section.columns -%}\n\t\t\t{%- for df in column.fields -%}{%- set ignored = section_fieldnames.append(df.fieldname) -%}{%- endfor -%}\n\t\t{%- endfor -%}\n\t\t{%- if \"total\" in section_fieldnames -%}\n\t\t{#- \"total\" sits in a 3-column section, so its label/value grid does not line up with the\n\t\t Taxes and Totals sections below it. Render it in the same right-half 6/6 grid they use. -#}\n\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t{%- for column in section.columns -%}{{ render_fields(column.fields, 1) }}{%- endfor -%}\n\t\t\t\t\t
\n\t\t\t\t
\n\t\t\t
\n\t\t{%- else -%}\n\t\t{% for column in section.columns %}\n\t\t\t
\n\t\t\t{%- if loop.first and \"in_words\" in section_fieldnames and doc.in_words -%}\n\t\t\t{#- The Totals section's left column is empty in print; put the amount in words there,\n\t\t\t on the same line as Grand Total, instead of under Rounded Total on the right. -#}\n\t\t\t\t
\n\t\t\t\t\t
{{ doc.in_words }}
\n\t\t\t\t
\n\t\t\t{%- endif -%}\n\t\t\t{{ render_fields(column.fields, no_of_cols) }}\n\t\t\t
\n\t\t{% endfor %}\n\t\t{%- endif -%}\n\t
\n\t{% endfor %}\n\n\t{% if loop.last and bank_account %}\n\t
\n\t\t{%- if doc.print_line_breaks -%}
{%- endif -%}\n\t\t
\n\t\t\t

{{ _(\"Bank Account Details\") }}

\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t{% if bank_account.bank_account_no %}\n\t\t\t\t\t\n\t\t\t\t\t{% endif %}\n\t\t\t\t\t{% if bank_account.iban %}\n\t\t\t\t\t\n\t\t\t\t\t{% endif %}\n\t\t\t\t\t{% if bank_account.branch_code %}\n\t\t\t\t\t\n\t\t\t\t\t{% endif %}\n\t\t\t\t\t{% if bank_account.swift_number %}\n\t\t\t\t\t\n\t\t\t\t\t{% endif %}\n\t\t\t\t\n\t\t\t\n\t\t
\n\t
\n\t{% endif %}\n\n\t{% if loop.last %}\n\t
\n\t\t
\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t
\n\t\t\t\t\t\t\t
{{ _(\"On behalf of\") }} {{ doc.customer_name or doc.customer }}
\n\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t
{{ _(\"Receiver\") }}{{ _(\"Date\") }}
\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t
{{ _(\"On behalf of\") }} {{ doc.company }}
\n\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t
{{ _(\"Issuer\") }}{{ _(\"Date\") }}
\n\t\t\t\t\t\t
\n\t\t
\n\t
\n\t{% endif %}\n\n\t
\n\t\t{% if not no_letterhead and footer %}\n\t\t
\n\t\t\t{{ footer }}\n\t\t
\n\t\t{% endif %}\n\t\t{% if print_settings.repeat_header_footer %}\n\t\t\t

\n\t\t\t\t{{ _(\"Page {0} of {1}\").format('', '') }}\n\t\t\t

\n\t\t{% endif %}\n\t
\n
\n{% endfor %}\n\n\n\n\n\n\n\n\n", "line_breaks": 0, "margin_bottom": 15.0, "margin_left": 15.0,