Qweb - 错误 - 打印时未找到公司徽标

时间:2016-10-25 12:35:02

标签: report openerp

在设置中 - >公司 - >添加了图片[Logo]。在其中两份报告中,印有此徽标。但是,当打印销售订单时,我收到此错误

Error while printing the sale order 出现徽标的报告代码与销售订单报告相同。在这两份报告中,它需要公司徽标和打印出来。没错。但我只在销售订单报告中收到此错误。有人可以帮我解决这个错误吗?

代码供您参考:

r.db("test")
    .table("posts")
    .innerJoin(

        r.db("test")
        .table("user")
        .filter({
            "username": "super_admin"
        }),

        lambda posts,

        user: posts["user_id"] == user["id"]
    )
    .zip()

3 个答案:

答案 0 :(得分:0)

company不是全局变量,它可以与您对象上的每个图像一起使用。如果您要为对象添加图像,那么保存图像的对象变量引用和字段名称应该是正确的表达式。

如果您尝试在报告中添加公司徽标,则需要在对象上使用company_id字段以获取公司图片。

贝斯茨

答案 1 :(得分:0)

@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'**

答案 2 :(得分:0)

<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 =&#34; module.report_saleorder_document&#34;之前给出。吨琅=&#34; doc.partner_id.lang&#34;现在它和哥们一起工作!

相关问题