Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
3 Trả lời
4924 Lượt xem

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?

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi Esther,

Could you help me with this?

Odoo10c, coud I reuse loop for order lines?

Thanks,

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

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>

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 10 24
4188
1
thg 4 25
1081
2
thg 3 25
1238
4
thg 11 24
6991
1
thg 3 24
1910