QWEB - IndexError: list index out of range
QWEB - IndexError: list index out of range
我正在尝试创建 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>
问题:当我select打印所有产品时,出现错误(见下文)。但是当我select只有一个产品时,我可以打印报告。
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
class 作为包装器,因为引擎使用它来获取报告页面。你可以看看 source code.
我正在尝试创建 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>
问题:当我select打印所有产品时,出现错误(见下文)。但是当我select只有一个产品时,我可以打印报告。
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
class 作为包装器,因为引擎使用它来获取报告页面。你可以看看 source code.