This question has been flagged
3 Replies
3844 Views

Imagine the invoice template. A <tfoot> element in the table that shows invoice lines seems like a good way of showing page totals in every... page. However, just as in <thead>, the <tfoot> element can't access the values I set while looping over the invoice lines.

Does anyone know of a way to deal with this?

Avatar
Discard
Best Answer

Hi Esther,

Could you help me with this?

Odoo10c, coud I reuse loop for order lines?

Thanks,

Avatar
Discard
Author Best Answer

Thank you!

I'd say this is a good - and simple -, example of what I'm trying to do (any error in the code should be considered as a typo):


<table>
    <t t-set="myVariable" t-value="0"/>

    <thead>
        <tr>
            <th>A</th>
            <th>B</th>
            <th>C</th>
        </tr>
    </thead>
   
    <tfoot>
        <tr>
            <td colspan="3"><t t-esc="myVariable"/></td>
        </tr>
    </tfoot>

    <tbody>
        <t t-foreach="o.invoice_line_ids" t-as="l">
            <t t-set="myVariable" t-value="myVariable+l.price_subtotal"/>

            <tr>
                <td><t t-field="l.name"/></td>
                <td><t t-field="l.quantity"/></td>
                <td><t t-field="l.price_subtotal"/></td>
            </tr>
        </t>
    </tbody>
</table>

Avatar
Discard
Best Answer

You can set the loop before and set the tfoot inside of it. You can post your code and I will help you with that.

Avatar
Discard