在 Odoo v10 上生成 PDF 报告时缺少条形码
Missing Barcode at Generate PDF Report on Odoo v10
我正在尝试将产品标签生成为 PDF,它已生成但缺少产品条码。
但是同一个 Qweb 我生成了 HTML 的产品标签并且它工作正常。
转到产品和 select 两个:
将产品标签生成为 HTML(工作正常):
将产品标签生成为 PDF(缺少条码):
这是我的QWEB:
<?xml version="1.0"?>
<t t-name="product.report_productlabel">
<t t-call="report.html_container">
<div class="page">
<style>
</style>
<t t-foreach="docs" t-as="template">
<t t-foreach="template.product_variant_ids" t-as="product">
<div class="col-xs-6" style="padding:0;">
<table style="border-spacing:0;margin-bottom:0;height: 110px;border: 2px solid black;" class="table">
<thead>
<tr style="width: 3in;">
<td style="width: 2.63in;text-align: center;background-color: #fff;" colspan="2" class="col-xs-8 danger">
<strong style="text-transform: uppercase;">
<t t-esc="product.name"/>
</strong>
</td>
</tr>
</thead>
<tbody>
<tr style="width: 1in;">
<td style="text-align: center; border-top: 0px solid #fff; padding: 0px 5px 0px 5px;" class="col-xs-5">
<h4 style="border: 4px solid #ff4040;border-radius: 9px;background-color: #ffff00;padding: 10px 12px 10px 12px;font-size: 26px;margin-top: 0px;margin-bottom: 0px;">
<strong t-field="product.list_price" />
<strong>
<t t-esc="product.company_id.currency_id.symbol"/>
</strong>
</h4>
</td>
<td style="text-align: center;border-top: 0px solid #fff;padding: 0px 5px 0px 5px;" class="col-xs-7">
<img class="img-responsive"
t-att-src="'data:image/png;base64,%s' % res_company.logo"
style="background-color: #fff;margin-left: auto;margin-right: auto;width: auto;height: 16px;margin-bottom: 8px;"/>
<img class="img-responsive" t-if="product.barcode"
t-att-src="'/report/barcode/?type=%s&value=%s&width=%s&height=%s' % ('EAN13', product.barcode, 650, 200)"
style="height: 20px;width: 100%;"/>
<span style="">
<t t-esc="product.barcode"/>
</span>
</td>
</tr>
</tbody>
</table>
</div>
</t>
</t>
</div>
当你在代理后面时,这是一个问题,在你的例子中是 NGNIX。但我可以按照以下步骤修复它:
第一个解:
1- 在 odoo/addons/report/models/report.py 文件行号 205 中添加以下行:
#base_url = irconfig_obj.get_param('report.url') or irconfig_obj.get_param('web.base.url')
base_url = irconfig_obj.get_param('web.base.url.report')
2- 添加服务器参数 web.base.url.report,值为“http://127.0.0.1:8069”(运行 端口)。
(With the Debug Actived) Go to Settings -> Parameters -> System
Parameters -> Create
3- 重启 Odoo 服务器即可。
/etc/init.d/odoo restart
感谢@CZoellner 的更新:
@CZoellner
建议也有效,不要更改代码中的任何内容:
第二种解决方案(推荐):
1- 添加或更新服务器参数 url.report 值为“http://127.0.0.1:8069”(运行 端口)。
(With the Debug Actived) Go to Settings -> Parameters -> System
Parameters -> Create
2- 重启 Odoo 服务器即可。
/etc/init.d/odoo restart
我正在尝试将产品标签生成为 PDF,它已生成但缺少产品条码。
但是同一个 Qweb 我生成了 HTML 的产品标签并且它工作正常。
转到产品和 select 两个:
将产品标签生成为 HTML(工作正常):
将产品标签生成为 PDF(缺少条码):
这是我的QWEB:
<?xml version="1.0"?>
<t t-name="product.report_productlabel">
<t t-call="report.html_container">
<div class="page">
<style>
</style>
<t t-foreach="docs" t-as="template">
<t t-foreach="template.product_variant_ids" t-as="product">
<div class="col-xs-6" style="padding:0;">
<table style="border-spacing:0;margin-bottom:0;height: 110px;border: 2px solid black;" class="table">
<thead>
<tr style="width: 3in;">
<td style="width: 2.63in;text-align: center;background-color: #fff;" colspan="2" class="col-xs-8 danger">
<strong style="text-transform: uppercase;">
<t t-esc="product.name"/>
</strong>
</td>
</tr>
</thead>
<tbody>
<tr style="width: 1in;">
<td style="text-align: center; border-top: 0px solid #fff; padding: 0px 5px 0px 5px;" class="col-xs-5">
<h4 style="border: 4px solid #ff4040;border-radius: 9px;background-color: #ffff00;padding: 10px 12px 10px 12px;font-size: 26px;margin-top: 0px;margin-bottom: 0px;">
<strong t-field="product.list_price" />
<strong>
<t t-esc="product.company_id.currency_id.symbol"/>
</strong>
</h4>
</td>
<td style="text-align: center;border-top: 0px solid #fff;padding: 0px 5px 0px 5px;" class="col-xs-7">
<img class="img-responsive"
t-att-src="'data:image/png;base64,%s' % res_company.logo"
style="background-color: #fff;margin-left: auto;margin-right: auto;width: auto;height: 16px;margin-bottom: 8px;"/>
<img class="img-responsive" t-if="product.barcode"
t-att-src="'/report/barcode/?type=%s&value=%s&width=%s&height=%s' % ('EAN13', product.barcode, 650, 200)"
style="height: 20px;width: 100%;"/>
<span style="">
<t t-esc="product.barcode"/>
</span>
</td>
</tr>
</tbody>
</table>
</div>
</t>
</t>
</div>
当你在代理后面时,这是一个问题,在你的例子中是 NGNIX。但我可以按照以下步骤修复它:
第一个解:
1- 在 odoo/addons/report/models/report.py 文件行号 205 中添加以下行:
#base_url = irconfig_obj.get_param('report.url') or irconfig_obj.get_param('web.base.url')
base_url = irconfig_obj.get_param('web.base.url.report')
2- 添加服务器参数 web.base.url.report,值为“http://127.0.0.1:8069”(运行 端口)。
(With the Debug Actived) Go to Settings -> Parameters -> System Parameters -> Create
3- 重启 Odoo 服务器即可。
/etc/init.d/odoo restart
感谢@CZoellner 的更新:
@CZoellner
建议也有效,不要更改代码中的任何内容:
第二种解决方案(推荐):
1- 添加或更新服务器参数 url.report 值为“http://127.0.0.1:8069”(运行 端口)。
(With the Debug Actived) Go to Settings -> Parameters -> System Parameters -> Create
2- 重启 Odoo 服务器即可。
/etc/init.d/odoo restart