跳至內容
選單
此問題已被標幟
3 回覆
4991 瀏覽次數

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
4260
1
4月 25
1221
2
3月 25
1372
4
11月 24
7090
1
3月 24
2010