That’s right. I’m escaping the \\
now with another set of \\
but it would be nice if that can be prevented.

I think it should be the job of relatorio to escape LaTeX special chars. … Else you could finish with shell escaping (which is possible if I recall correctly).
It would be nice indeed. But I didn’t go that deep into the problem because it works for me I’m not using dollars and I also don’t like to have the currency symbol on each invoice line. I am just sending
False
in the function so you don’t get the currency symbol but only the formatted number so you have to add the currency symbol yourself. But this should be a general implementation so this escaping should be fixed.
That said, below you can find the template. I left out the taxes because in the demo there are no taxes, but I am pretty sure you know more about LaTeX then I do so it shouldn’t be a problem for you to add this.
The LaTeX template
{%for invoice in records %}
${set_lang(invoice.party.lang)}
\documentclass[11pt]{article}
\usepackage[a4paper,hmargin=1cm,vmargin=1cm]{geometry}
\usepackage[parfill]{parskip} % Do not indent paragraphs
\usepackage{longtable}
\usepackage[table]{xcolor}
\usepackage{lastpage}
\linespread{1.5} % Line spacing
\pagestyle{empty} % No page numbers
\begin{document}
%----------------------------------------------------------------------------------------
% Party details move it to the right
%----------------------------------------------------------------------------------------
{\addtolength{\leftskip}{11cm}
{% for line in invoice.invoice_address.full_address.split('\n') %}\
${line} \\\\
{% end %}\
{% if invoice.party_tax_identifier %}\
${invoice.party_tax_identifier.type_string} : ${invoice.party_tax_identifier.code}
{% end %}
}
%----------------------------------------------------------------------------------------
% What kind of invoice is this
%----------------------------------------------------------------------------------------
\centerline{
{% if invoice.type == 'in' %}\
\Large\underline{\bf{Supplier Invoice No: ${invoice.number and '' + invoice.number or ''}}}
{% end %}\
{% if invoice.type == 'out' %}\
{% choose %}\
{% when invoice.state == 'draft' %}\
\Large\underline{\bf{Draft Invoice}}
{% end %}\
{% when invoice.state == 'validated' %}\
\Large\underline{\bf{Pro Forma Invoice}}
{% end %}\
{% otherwise %}\
\Large\underline{\bf{Invoice No: ${invoice.number and '' + invoice.number or ''}}}
{% end %}\
{% end %}\
{% end %}\
}
%----------------------------------------------------------------------------------------
% Invoice details
%----------------------------------------------------------------------------------------
Description: ${invoice.description or ''} \\\\
Reference: ${invoice.origins or ''} \\\\
Date: ${format_date(invoice.invoice_date or today, invoice.party.lang)}
{% if invoice.tax_identifier %}\
\\\\${invoice.tax_identifier.type_string}: ${invoice.tax_identifier.code}
{% end %}\
%----------------------------------------------------------------------------------------
% Build the list of invoice lines. First describe the header, then add the lines
%----------------------------------------------------------------------------------------
\setlength\LTleft{0pt}
\setlength\LTright{0pt}
\begin{longtable}{|p{7cm}|p{2.5cm}|p{2.5cm}|p{2.5cm}|p{2.5cm}|}
\hline
\rowcolor[HTML]{cccccc}
\multicolumn{1}{|l|}{\bf Description}
& \multicolumn{1}{r|}{\bf Quantity}
& \multicolumn{1}{r|}{\bf Unit Price}
& \multicolumn{1}{c|} {\bf Taxes}
& \multicolumn{1}{r|}{\bf Amount} \\\\*
\hline\hline
\endfirsthead
{\bf Description} & {\bf Quantity} & {\bf Unit Price} & {\bf Taxes} & {\bf Amount} \\\\*
\hline\hline
\endhead
\endfoot
\hline
\endlastfoot
{% for line in invoice.lines %}\
{% choose %}
{% when line.type == 'line' %}\
{% if line.product %}\
${line.product.rec_name}
{% end %}\
{% if line.description %}\
{% for l in line.description.split('\n') %}
\\\\${l}
{% end %}\
{% end %}\
& \multicolumn{1}{r|}{${ (format_number(line.quantity, invoice.party.lang, digits=line.unit_digits) + (line.unit and (' ' + line.unit.symbol) or '')) or '' }}
& \multicolumn{1}{r|}{${ format_currency(line.unit_price, invoice.party.lang, invoice.currency, digits=line.__class__.unit_price.digits[1]) }}
& \multicolumn{1}{c|}{-}
& \multicolumn{1}{r|}{${ format_currency(line.amount, invoice.party.lang, invoice.currency) }} \\\\
{% end %}\
{% when line.type =='subtotal' %}
\multicolumn{4}{l}{%
{% for description in (line.description or '').split('\n') %}
${description}
{% end %}
} & ${line.amount} \\\\
{% end %}\
{% when line.type == 'title' %}\
{% for description in (line.description or '').split('\n') %}\
\\\\${description}
{% end %}
{% end %}\
{% otherwise %}
{% for description in (line.description or '').split('\n') %}\
\\\\${description}
{% end %}
{% end %}\
{% end %}
{% end %}\
\end{longtable}
\begin{table}[h]
%----------------------------------------------------------------------------------------
% tax table
%----------------------------------------------------------------------------------------
\begin{tabular}{ |p{2cm}|p{2cm}|p{2cm}| }
\hline
\rowcolor[HTML]{cccccc}
\multicolumn{1}{|l|}{\bf Tax}
& \multicolumn{1}{r|}{\bf Base}
& \multicolumn{1}{r|}{\bf Amount} \\\\*
\hline
\end{tabular}
\hfill
%----------------------------------------------------------------------------------------
% Totals table
%----------------------------------------------------------------------------------------
\begin{tabular}{ p{4cm}|p{5cm}| }
\hline
\multicolumn{1}{|r|}{\cellcolor[HTML]{cccccc}{\bf Total (excl. taxes):}}
& \multicolumn{1}{r|}{${ format_currency(invoice.untaxed_amount, invoice.party.lang, invoice.currency) }}\\\\*
\hline
\multicolumn{1}{|r|}{\cellcolor[HTML]{cccccc}{\bf Taxes:}}
& \multicolumn{1}{r|}{${ format_currency(invoice.tax_amount, invoice.party.lang, invoice.currency) }}\\\\*
\hline
\multicolumn{1}{|r|}{\cellcolor[HTML]{cccccc}{\bf Total:}}
& \multicolumn{1}{r|}{${ format_currency(invoice.total_amount, invoice.party.lang, invoice.currency) }}\\\\*
\hline
\end{tabular}
\end{table}
\thepage \hspace{1pt} of \pageref{LastPage}
\end{document}
{% end %}
I really appreciate any comment on the template!