跳至内容
菜单
此问题已终结
3 回复
4875 查看

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?

形象
丢弃
最佳答案

Hi Esther,

Could you help me with this?

Odoo10c, coud I reuse loop for order lines?

Thanks,

形象
丢弃
编写者 最佳答案

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>

形象
丢弃
最佳答案

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.

形象
丢弃
相关帖文 回复 查看 活动
0
10月 24
4158
1
4月 25
1034
2
3月 25
1162
4
11月 24
6920
1
3月 24
1856