QWEB索引器错误:列表索引超出范围

2024-05-23 18:30:38 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试创建一个QWeb报表。我有一份产品清单,我想把每种礼仪都印在同一页上。这是我的代码:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <!-- Déclaration des rapports -->
            <report 
                id="etiquette_produit"
                model="product.template"
                string="Etiquette Produit"
                report_type="qweb-pdf"
                file="Product_Etiquette_QWeb.produit_etiquette"
                name="Product_Etiquette_QWeb.produit_etiquette"
            />

        <template id="produit_etiquette">
            <t t-call="report.external_layout">
                <t t-foreach="docs" t-as="o">
                    <div class="page">
                        <table class="table table-striped">
                            <tr>
                                <td class="col-xs-1"><span t-field="o.default_code"/></td>
                                <td class="col-xs-5 text-center"><span t-field="o.name"/></td>
                                <td class="col-xs-1"><span t-field="o.default_code"/></td>
                                <td class="col-xs-5 text-center"><span t-field="o.name"/></td>
                            </tr>
                            <tr>
                                <td colspan="2" class="text-center">* M E 2 1 5 9 *</td>
                                <td colspan="2" class="text-center">* M E 2 0 1 7 *</td>
                            </tr>
                        </table>
                    </div>
                </t>
            </t>
        </template>
    </data>
</openerp>

问题:当我选择所有要打印的产品时,我有一个错误(见下文)。但是当我只选择一种产品时,我可以打印报告。在

^{pr2}$

有什么想法吗?在


Tags: textreportfield产品tablecoltrclass
1条回答
网友
1楼 · 发布于 2024-05-23 18:30:38

这个问题与报表引擎期望每个页面有1个页眉和页脚有关。您正在为1个页眉+页脚创建N个页面。在

调用<t t-call="report.external_layout">必须放在for循环中。如果在同一个页面中需要多个项目,请不要使用page类作为包装器,因为引擎使用这个类来获取报表页面。你可以看看source code。在

相关问题 更多 >