python - QWEB - 索引错误 : list index out of range

标签 python odoo odoo-8 qweb

我正在尝试创建 QWeb 报告。我有一份产品 list ,我想在同一页上打印每项礼仪。这是我的代码:

<?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>

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

Odoo Server Error

Traceback (most recent call last):
  File "/opt/odoo/odoo-server/addons/report/controllers/main.py", line 116, in report_download
    response = self.report_routes(reportname, docids=docids, converter='pdf')
  File "/opt/odoo/odoo-server/openerp/http.py", line 405, in response_wrap
    response = f(*args, **kw)
  File "/opt/odoo/odoo-server/addons/report/controllers/main.py", line 65, in report_routes
    pdf = report_obj.get_pdf(cr, uid, docids, reportname, data=options_data, context=context)
  File "/opt/odoo/odoo-server/openerp/api.py", line 268, in wrapper
    return old_api(self, *args, **kwargs)
  File "/opt/odoo/odoo-server/addons/report/models/report.py", line 275, in get_pdf
    paperformat, specific_paperformat_args, save_in_attachment
  File "/opt/odoo/odoo-server/openerp/api.py", line 268, in wrapper
    return old_api(self, *args, **kwargs)
  File "/opt/odoo/odoo-server/addons/report/models/report.py", line 432, in _run_wkhtmltopdf
    head_file.write(headers[index])
IndexError: list index out of range

有什么想法吗?

最佳答案

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

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

关于python - QWEB - 索引错误 : list index out of range,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37569444/

相关文章:

odoo - 停止在 odoo 中的特定模型中创建邮件消息和关注者

sql - 根据sql中的月份和年份选择一行

python - 覆盖 Django Rest ViewSets 删除行为

python - Django Rest Framework 用户名/密码无效

javascript - call_button() 缺少 1 个必需的位置参数 : 'method' odoo

odoo - odoo POS 工作原理

python-2.7 - 奥多 : Write function in Odoo 8

android - 如何知道最近 5 秒内 postgresql 的变化数据

python 到 c 的过渡

python - 使用正则表达式捕获 Python 脚本中的所有字符串