Hi all,
I have got custom Macros in standard_macros.html since the beginning of v4.0. The transition to v7 was absolutely no problem. Thanks to the developers
But now one question arises:
we have the add_header function with max_pages and page_num. I want the same function in a custom macro called âadd_header2â.
Actually it looks like the following:
{%- macro add_header2(doc, letter_head, no_letterhead, page_num, max_pages) -%}
{% if letter_head and not no_letterhead %}
<div class="letter-head">{{ letter_head }}</div>
{% endif %}
<table width="100%">
<tr>
<td width="60%">
{% if doc.doctype == "Purchase Order" %}
<p style="line-height:145%;">{{ doc.supplier_name }}<br>{{ doc.address_display }}<br>
<div id="test" style="display:none;"></div>
</p>
{% else %}
<p style="line-height:145%;">{{ doc.customer_name }}<br>{{ doc.address_display }}<br>
<div id="test" style="display:none;"></div>
</p>
{% endif %}
</td>
<td width="40%">
<!-- Rechnungsnummer und so -->
<table style="line-height:105%;" width="100%">
<tr>
<td width="50%">Belegnummer</td>
<td width="50%" style="text-align:right;">{{ doc.name }}</td>
</tr>
</table>
</td>
</tr>
</table>
<br><br>
<table width="100%">
<tr>
<td width="50%">
<div id="Rechnung">
</div>
{% if page_num != max_pages %}
{% if doc.doctype == "Sales Invoice" %}
<big><big><big><big>Rechnung </big></big></big></big>
{% elif doc.doctype == "Purchase Order" %}
<big><big><big><big>Bestellung </big></big></big></big>
{% elif doc.doctype == "Delivery Note" %}
<big><big><big><big>Lieferschein </big></big></big></big>
{% elif doc.doctype == "Sales Order" %}
<big><big><big><big>Auftragsbestätigung </big></big></big></big>
{% elif doc.doctype == "Quotation" %}
<big><big><big><big>Angebot </big></big></big></big>
{% elif doc.doctype == "Customer Issue" %}
<big><big><big><big>Kundenreklamation </big></big></big></big>
{% else %}
<big><big><big><big>{{ doc.doctype }} </big></big></big></big>
{% endif %}
{% endif %}
</td>
<td width="50%" style="text-align:right; valign:top;">
{% if doc.doctype == "Purchase Order" %}
{% elif doc.doctype == "Customer Issue" %}
{% elif doc.doctype == "Quotation" %}
<b>Datum:</b> {{ doc.get_formatted("transaction_date") }}<br>
{% elif doc.doctype == "Sales Order" %}
<b>Datum:</b> {{ doc.get_formatted("transaction_date") }}<br>
{% else %}
<b>Datum:</b> {{ doc.get_formatted("posting_date") }}<br>
{% endif %}
</td>
</tr>
</table>
<br><br>
{%- endmacro -%}
{%- macro add_header3(page_num, max_pages, doc, letter_head, no_letterhead, footer) -%}
{% if letter_head and not no_letterhead %}
<div style="width:100% !important;">{{ letter_head }}</div>
{% endif %}
{% if doc.print_heading_template %}
{{ frappe.render_template(doc.print_heading_template, {"doc":doc}) }}
{% else %}
<div class="">
</div>
{% endif %}
{%- if doc.meta.is_submittable and doc.docstatus==0-%}
{%- endif -%}
{%- if doc.meta.is_submittable and doc.docstatus==2-%}
{%- endif -%}
{%- endmacro -%}
There is no problem rendering the fields expect one thingâŚnum_pages and max_pages is there a clue to fix it?
Dan