Print Format create error

Hi,

i just tried create new print format for purchase order and getting this error :
Traceback (innermost last):
File “/home/sigma/frappe-bench/apps/frappe/frappe/app.py”, line 51, in application
response = frappe.handler.handle()
File “/home/sigma/frappe-bench/apps/frappe/frappe/handler.py”, line 62, in handle
execute_cmd(cmd)
File “/home/sigma/frappe-bench/apps/frappe/frappe/handler.py”, line 85, in execute_cmd
ret = frappe.call(method, **frappe.form_dict)
File “/home/sigma/frappe-bench/apps/frappe/frappe/init.py”, line 708, in call
return fn(*args, **newargs)
File “/home/sigma/frappe-bench/apps/frappe/frappe/templates/pages/print.py”, line 107, in get_html
html = template.render(args, filters={“len”: len})
File “/home/sigma/frappe-bench/env/local/lib/python2.7/site-packages/jinja2/environment.py”, line 969, in render
return self.environment.handle_exception(exc_info, True)
File “/home/sigma/frappe-bench/env/local/lib/python2.7/site-packages/jinja2/environment.py”, line 742, in handle_exception
reraise(exc_type, exc_value, tb)
File "

and my code is :
Custom code :
{%- macro add_header(page_num, max_pages, doc, letter_head, no_letterhead) -%}
{% if letter_head and not no_letterhead %}

{{ letter_head }}

{% endif %}
{%- if doc.meta.is_submittable and doc.docstatus==0-%}

{{ _(“DRAFT”) }}


{%- endif -%}
{%- if doc.meta.is_submittable and doc.docstatus==2-%}

{{ _(“CANCELLED”) }}


{%- endif -%}
{% if max_pages > 1 %}

{{ _(“Page #{0} of {1}”).format(page_num, max_pages) }}


{% endif %}
{%- endmacro -%}

.table-hover>tbody>tr:hover>td, .table-hover>tbody>tr:hover>th { background-color: #B7CCF2; color:#000000; font-size:16px; } .print-format table, .print-format tr, .print-format td, .print-format div, .print-format p { font-family: sans-serif; line-height: 90%; vertical-align: middle; } @media screen { .print-format { width: 210mm; padding: 10mm; min-height: 297mm; footer {page-break-after: always;} } } {{ add_header(0,1,doc,letter_head, no_letterhead) }}
{{ doc.select_print_heading or (doc.print_heading if doc.print_heading != None else _(doc.doctype)) }} {{ _("#") }}{{ doc.name }}
{{ _("To") }}: {{ doc.customer_name }}
{{ _("Address") }}: {{ doc.address_display }}
{{ _("Ship To") }}: {{ doc.shipping_address_title }}
{{ _("Address") }}: {{ doc.shipping_address }}
{{ _("Date") }}: {{ doc.get_formatted("transaction_date") }}
{{ _("PO #") }}: {{ doc.po_no }}
{{ _("PO Date") }}: {{ doc.get_formatted("po_date") }}
{%- for row in doc.sales_order_details -%} {%- endfor -%}
Sr Description Qty Rate Amount
{{ row.idx }} {{ row.description }} {{ row.qty }} {{ row.uom or row.stock_uom }} {{ row.get_formatted("rate", doc) }} {{ row.get_formatted("amount", doc) }}

{% if doc.terms %} {{ _("Auxiliary Information") }}: {{ doc.terms or "" }} {%- endif -%}

{% if doc.in_words_export %} {{ _("Total Amount (In Words)") }}:
{{ doc.in_words_export }} {%- endif -%}



{{ _("Received By:") }}
{{ _("Customer Sign") }}
</td>
{%- for row in doc.other_charges -%} {%- if not row.included_in_print_rate -%} {%- if row.tax_amount -%} {%- endif -%} {%- endif -%} {%- endfor -%} {%- if doc.discount_amount -%} {%- endif -%}
    </table>

</td>
{{ _("Net Total") }} {{ doc.get_formatted("net_total_export") }}
{{ row.description }} {{ row.get_formatted("tax_amount", doc) }}
{{ _("Discount") }} {{ doc.get_formatted("discount_amount") }}
{{ _("Grand Total") }} {{ doc.get_formatted("grand_total_export") }}
{% if doc.get("other_charges", filters={"included_in_print_rate": 1}) %}

Taxes Included:

{%- for row in doc.other_charges -%} {%- if row.included_in_print_rate -%}
            {{ row.description }}
        </td>
        <td class="text-right">
            {{ row.get_formatted("tax_amount", doc) }}
        </td>
    <tr>
    {%- endif -%}
    {%- endfor -%}
</tbody>
{%- endif -%}

please help on this…

Check this print format for sales order.

Hi,

If the error in the code i can look for it, but i think the error that i see is not because of the code

THanks

@bobzz_zone Kindly send us formatted code that we can look at. Better, use a tool like gist.github.com

Here the code,

@bobzz_zone
Your code run successful for Sales Order.
I found no error in your code.