Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
3 Odpovědi
4987 Zobrazení

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
Zrušit
Nejlepší odpověď

Hi Esther,

Could you help me with this?

Odoo10c, coud I reuse loop for order lines?

Thanks,

Avatar
Zrušit
Autor Nejlepší odpověď

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
Zrušit
Nejlepší odpověď

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
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
0
říj 24
4255
1
dub 25
1221
2
bře 25
1369
4
lis 24
7089
1
bře 24
2009