Qweb - 错误 - 打印时未找到公司徽标
Qweb - Error - Company Logo not found while printing
在设置-> 公司-> 添加图像 [徽标]。在其中两份报告中,印有此徽标。但是在打印销售订单时出现此错误
Error while printing the sale order
出现标识的报表代码与销售订单报表相同。在这两份报告中,它采用公司徽标并打印出来。没有错误。但我只在销售订单报告中收到此错误。谁能帮我解决这个错误?
供您参考的代码:
<div class="row">
<div class="col-xs-3">
<img t-if="company.logo" t-att-src="'data:image/png;base64,%s' % company.logo" style="max-height: 45px;"/>
</div>
<div class="col-xs-9 text-right" style="margin-top:20px;" t-field="company.rml_header1"/>
</div>
company
不是全局变量,它适用于您对象上的每个图像。如果您要为您的对象添加图像,那么您的对象变量引用和保存图像的字段名称应该在此处正确表达。
并且如果您尝试在报告中添加公司徽标,则需要在对象上使用 company_id 字段以获取公司图像。
最佳
@shodowsjedi
Below is the xml code for your reference
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="report_saleorder_document">
<t t-set="doc" t-value="doc.with_context({'lang':doc.partner_id.lang})" />
<div class="page">
<br/><br/><br/><br/>
<h2>
<span t-if="doc.state not in ['draft','sent']">Order # </span>
<span t-if="doc.state in ['draft','sent']">Quotation # </span>
<span t-field="doc.name"/>
</h2>
<div class="row mt32 mb32" id="informations">
<div t-if="doc.client_order_ref" class="col-xs-3">
<strong>Your Reference:</strong>
<p t-field="doc.client_order_ref"/>
</div>
<div t-if="doc.user_id.name" class="col-xs-3">
<strong>Salesperson:</strong>
<p t-field="doc.user_id"/>
</div>
<div name="payment_term" t-if="doc.payment_term_id" class="col-xs-3">
<strong>Payment Term:</strong>
<p t-field="doc.payment_term_id"/>
</div>
</div>
<!-- Is there a discount on at least one line? -->
<t t-set="display_discount" t-value="any([l.discount for l in doc.order_line])"/>
<table class="table table-condensed">
<thead>
<tr>
<th>Description</th>
<th class="text-right">Quantity</th>
<th class="text-right">Unit Price</th>
<th t-if="display_discount" class="text-right"><span groups="sale.group_discount_per_so_line">Disc.(%)</span></th>
<th class="text-right">Taxes</th>
<th class="text-right">Price</th>
</tr>
</thead>
<tbody class="sale_tbody">
<t t-foreach="doc.order_line" t-as="l">
<tr t-if="l.product_uom_qty">
<td>
<span t-field="l.name"/>
</td>
<td class="text-right">
<span t-field="l.product_uom_qty"/>
<span groups="product.group_uom" t-field="l.product_uom"/>
</td>
<td class="text-right">
<span t-field="l.price_unit"/>
</td>
<td t-if="display_discount" class="text-right" groups="sale.group_discount_per_so_line">
<span t-field="l.discount"/>
</td>
<td class="text-right">
<span t-esc="', '.join(map(lambda x: (x.description or x.name), l.tax_id))"/>
</td>
<td class="text-right">
<span t-field="l.price_subtotal"
t-field-options='{"widget": "monetary", "display_currency": "doc.pricelist_id.currency_id"}'/>
</td>
</tr>
</t>
</tbody>
</table>
<div class="row" name="total">
<div class="col-xs-4 pull-right">
<table class="table table-condensed">
<tr class="border-black">
<td><strong>Total Without Taxes</strong></td>
<td class="text-right">
<span t-field="doc.amount_untaxed"
t-field-options='{"widget": "monetary", "display_currency": "doc.pricelist_id.currency_id"}'/>
</td>
</tr>
<tr>
<td>Taxes</td>
<td class="text-right">
<span t-field="doc.amount_tax"
t-field-options='{"widget": "monetary", "display_currency": "doc.pricelist_id.currency_id"}'/>
</td>
</tr>
<tr class="border-black">
<td><strong>Total</strong></td>
<td class="text-right">
<span t-field="doc.amount_total"
t-field-options='{"widget": "monetary", "display_currency": "doc.pricelist_id.currency_id"}'/>
</td>
</tr>
</table>
</div>
</div>
<p t-field="doc.note" />
<p t-if="doc.payment_term_id.note">
<span t-field="doc.payment_term_id.note"/>
</p>
<p t-if="not doc.payment_term_id and doc.partner_id.property_payment_term_id">
<span t-field="doc.partner_id.property_payment_term_id.note"/>
</p>
<p id="fiscal_position_remark" t-if="doc.fiscal_position_id and doc.fiscal_position_id.note">
<strong>Fiscal Position Remark:</strong>
<span t-field="doc.fiscal_position_id.note"/>
</p>
<div class="oe_structure"/>
<br/><br/><br/><br/>
<div class="text-center">
<p class="list-inline">
***************************
</p>
</div>
</div>
</template>
<template id="report_saleorder">
<t t-call="report.html_container">
<t t-foreach="docs" t-as="doc">
<t t-call="module.report_saleorder_document" t-lang="doc.partner_id.lang"/>
<br/><br/><br/>
<div class="header">
<div class="row">
<div class="row mt0 mb0">
<div class="col-xs-7">
<img t-if="doc.company_id.logo" t-att-src="'data:image/png;base64,%s' % doc.company_id.logo" style="max-height: 50 px;align:left;"/>
</div>
</div>
<div class="col-xs-9 text-right" style="margin-top:20px;" t-field="company.rml_header1"/>
<div class="row zero_min_height">
<div class="col-xs-12">
<div style="border-bottom: 1px solid black;"></div>
</div>
</div>
</div>
<div class="row">
<div><span><strong>Customer Address:</strong></span></div>
<div><span t-field="doc.partner_id.name"/></div>
<div><span t-field="doc.partner_id.street"/><br/><span t-field="doc.partner_id.street2"/></div>
<div><span t-field="doc.partner_id.city"/><span> - </span><span t-field="doc.partner_id.zip"/></div>
<div><span t-field="doc.partner_id.state_id.name"/><span>,</span><span t-field="doc.partner_id.country_id.name"/></div>
<div><span t-if="doc.partner_id.pan_number">PAN:<span t-field="doc.partner_id.pan_number"/></span></div>
</div>
<div class="col-xs-3 col-xs-offset-9">
<strong t-if="doc.state not in ['draft','sent']">Date Ordered:</strong>
<strong t-if="doc.state in ['draft','sent']">Quotation Date:</strong>
<p t-field="doc.date_order"/>
</div>
</div>
<div class="footer">
<div class="text-center" style="border-top: 1px solid black;">
<p class="list-inline">
***************************************
</p>
<ul class="list-inline">
<li>Page:</li>
<li><span class="page"/></li>
<li>/</li>
<li><span class="topage"/></li>
</ul>
</div>
</div>
</t>
</t>
</template>
</data>
</openerp>
**Error when running the above code
QWebException: 'NoneType' object has no attribute '_fields'**
<template id="report_saleorder">
<t t-call="report.html_container">
<t t-foreach="docs" t-as="doc">
<t t-call="module.report_saleorder_document" t-lang="doc.partner_id.lang"/>
<br/><br/><br/>
应该在 t t-call="module.report_saleorder_document" t-lang="doc.partner_id.lang" 之前给出,现在可以了,伙计!
在设置-> 公司-> 添加图像 [徽标]。在其中两份报告中,印有此徽标。但是在打印销售订单时出现此错误
Error while printing the sale order 出现标识的报表代码与销售订单报表相同。在这两份报告中,它采用公司徽标并打印出来。没有错误。但我只在销售订单报告中收到此错误。谁能帮我解决这个错误?
供您参考的代码:
<div class="row">
<div class="col-xs-3">
<img t-if="company.logo" t-att-src="'data:image/png;base64,%s' % company.logo" style="max-height: 45px;"/>
</div>
<div class="col-xs-9 text-right" style="margin-top:20px;" t-field="company.rml_header1"/>
</div>
company
不是全局变量,它适用于您对象上的每个图像。如果您要为您的对象添加图像,那么您的对象变量引用和保存图像的字段名称应该在此处正确表达。
并且如果您尝试在报告中添加公司徽标,则需要在对象上使用 company_id 字段以获取公司图像。
最佳
@shodowsjedi
Below is the xml code for your reference
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="report_saleorder_document">
<t t-set="doc" t-value="doc.with_context({'lang':doc.partner_id.lang})" />
<div class="page">
<br/><br/><br/><br/>
<h2>
<span t-if="doc.state not in ['draft','sent']">Order # </span>
<span t-if="doc.state in ['draft','sent']">Quotation # </span>
<span t-field="doc.name"/>
</h2>
<div class="row mt32 mb32" id="informations">
<div t-if="doc.client_order_ref" class="col-xs-3">
<strong>Your Reference:</strong>
<p t-field="doc.client_order_ref"/>
</div>
<div t-if="doc.user_id.name" class="col-xs-3">
<strong>Salesperson:</strong>
<p t-field="doc.user_id"/>
</div>
<div name="payment_term" t-if="doc.payment_term_id" class="col-xs-3">
<strong>Payment Term:</strong>
<p t-field="doc.payment_term_id"/>
</div>
</div>
<!-- Is there a discount on at least one line? -->
<t t-set="display_discount" t-value="any([l.discount for l in doc.order_line])"/>
<table class="table table-condensed">
<thead>
<tr>
<th>Description</th>
<th class="text-right">Quantity</th>
<th class="text-right">Unit Price</th>
<th t-if="display_discount" class="text-right"><span groups="sale.group_discount_per_so_line">Disc.(%)</span></th>
<th class="text-right">Taxes</th>
<th class="text-right">Price</th>
</tr>
</thead>
<tbody class="sale_tbody">
<t t-foreach="doc.order_line" t-as="l">
<tr t-if="l.product_uom_qty">
<td>
<span t-field="l.name"/>
</td>
<td class="text-right">
<span t-field="l.product_uom_qty"/>
<span groups="product.group_uom" t-field="l.product_uom"/>
</td>
<td class="text-right">
<span t-field="l.price_unit"/>
</td>
<td t-if="display_discount" class="text-right" groups="sale.group_discount_per_so_line">
<span t-field="l.discount"/>
</td>
<td class="text-right">
<span t-esc="', '.join(map(lambda x: (x.description or x.name), l.tax_id))"/>
</td>
<td class="text-right">
<span t-field="l.price_subtotal"
t-field-options='{"widget": "monetary", "display_currency": "doc.pricelist_id.currency_id"}'/>
</td>
</tr>
</t>
</tbody>
</table>
<div class="row" name="total">
<div class="col-xs-4 pull-right">
<table class="table table-condensed">
<tr class="border-black">
<td><strong>Total Without Taxes</strong></td>
<td class="text-right">
<span t-field="doc.amount_untaxed"
t-field-options='{"widget": "monetary", "display_currency": "doc.pricelist_id.currency_id"}'/>
</td>
</tr>
<tr>
<td>Taxes</td>
<td class="text-right">
<span t-field="doc.amount_tax"
t-field-options='{"widget": "monetary", "display_currency": "doc.pricelist_id.currency_id"}'/>
</td>
</tr>
<tr class="border-black">
<td><strong>Total</strong></td>
<td class="text-right">
<span t-field="doc.amount_total"
t-field-options='{"widget": "monetary", "display_currency": "doc.pricelist_id.currency_id"}'/>
</td>
</tr>
</table>
</div>
</div>
<p t-field="doc.note" />
<p t-if="doc.payment_term_id.note">
<span t-field="doc.payment_term_id.note"/>
</p>
<p t-if="not doc.payment_term_id and doc.partner_id.property_payment_term_id">
<span t-field="doc.partner_id.property_payment_term_id.note"/>
</p>
<p id="fiscal_position_remark" t-if="doc.fiscal_position_id and doc.fiscal_position_id.note">
<strong>Fiscal Position Remark:</strong>
<span t-field="doc.fiscal_position_id.note"/>
</p>
<div class="oe_structure"/>
<br/><br/><br/><br/>
<div class="text-center">
<p class="list-inline">
***************************
</p>
</div>
</div>
</template>
<template id="report_saleorder">
<t t-call="report.html_container">
<t t-foreach="docs" t-as="doc">
<t t-call="module.report_saleorder_document" t-lang="doc.partner_id.lang"/>
<br/><br/><br/>
<div class="header">
<div class="row">
<div class="row mt0 mb0">
<div class="col-xs-7">
<img t-if="doc.company_id.logo" t-att-src="'data:image/png;base64,%s' % doc.company_id.logo" style="max-height: 50 px;align:left;"/>
</div>
</div>
<div class="col-xs-9 text-right" style="margin-top:20px;" t-field="company.rml_header1"/>
<div class="row zero_min_height">
<div class="col-xs-12">
<div style="border-bottom: 1px solid black;"></div>
</div>
</div>
</div>
<div class="row">
<div><span><strong>Customer Address:</strong></span></div>
<div><span t-field="doc.partner_id.name"/></div>
<div><span t-field="doc.partner_id.street"/><br/><span t-field="doc.partner_id.street2"/></div>
<div><span t-field="doc.partner_id.city"/><span> - </span><span t-field="doc.partner_id.zip"/></div>
<div><span t-field="doc.partner_id.state_id.name"/><span>,</span><span t-field="doc.partner_id.country_id.name"/></div>
<div><span t-if="doc.partner_id.pan_number">PAN:<span t-field="doc.partner_id.pan_number"/></span></div>
</div>
<div class="col-xs-3 col-xs-offset-9">
<strong t-if="doc.state not in ['draft','sent']">Date Ordered:</strong>
<strong t-if="doc.state in ['draft','sent']">Quotation Date:</strong>
<p t-field="doc.date_order"/>
</div>
</div>
<div class="footer">
<div class="text-center" style="border-top: 1px solid black;">
<p class="list-inline">
***************************************
</p>
<ul class="list-inline">
<li>Page:</li>
<li><span class="page"/></li>
<li>/</li>
<li><span class="topage"/></li>
</ul>
</div>
</div>
</t>
</t>
</template>
</data>
</openerp>
**Error when running the above code
QWebException: 'NoneType' object has no attribute '_fields'**
<template id="report_saleorder">
<t t-call="report.html_container">
<t t-foreach="docs" t-as="doc">
<t t-call="module.report_saleorder_document" t-lang="doc.partner_id.lang"/>
<br/><br/><br/>
应该在 t t-call="module.report_saleorder_document" t-lang="doc.partner_id.lang" 之前给出,现在可以了,伙计!