【问题标题】:Why my custom report header is showing in html but not in pdf in Odoo v10?为什么我的自定义报告标题在 Odoo v10 中显示为 html 而不是 pdf?
【发布时间】:2018-05-22 21:46:21
【问题描述】:

我创建了一个继承sale.report_saleorder 的自定义报告,我正在尝试添加自定义标题。

<openerp>
    <data>
        <template id="report_saleorder_inherit" inherit_id="sale.report_saleorder">
            <xpath expr="t" position="before">
                <div class="head_wrap">
                    <div class="row">
                        <div class="col-xs-3">
                            <img t-if="res_company.logo" t-att-src="'data:image/png;base64,%s' %res_company.logo"
                                style="max-height: 45px;" />
                        </div>
                        <div class="col-xs-9 text-right" style="margin-top:20px;"
                            t-field="res_company.rml_header1" />
                    </div>
                    <div class="row zero_min_height">
                        <div class="col-xs-12">
                            <div style="border-bottom: 1px solid black;"></div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-xs-6" name="company_address">
                            <span t-field="res_company.partner_id"
                                t-field-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": true}'
                                style="border-bottom: 1px solid black; display:inline-block;" />
                        </div>
                    </div>
                </div>
            </xpath>
        </template>
    </data>
</openerp>

当我选择报告格式为“HTML”时,它可以正常工作。但是当我将它打印为“PDF”时,它不会呈现我的标题。有解决方案吗?如何打印带有标题的报告?

【问题讨论】:

  • 您解决了吗?我也遇到了同样的问题。

标签: header report odoo-10 odoo


【解决方案1】:

如果要使用自定义标头必须继承report.external_layout_header,这个:

<t t-name="report.external_layout_header">
    <div class="header">
        <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>
        <div class="row zero_min_height">
            <div class="col-xs-12">
                <div style="border-bottom: 1px solid black;"/>
            </div>
        </div>
        <div class="row">
            <div class="col-xs-5">
                <div t-field="company.partner_id" t-field-options="{&quot;widget&quot;: &quot;contact&quot;, &quot;fields&quot;: [&quot;address&quot;, &quot;name&quot;], &quot;no_marker&quot;: true}" style="border-bottom: 1px solid black;" class="pull-left"/>
            </div>
        </div>
    </div>
</t>

所以,你应该像这样继承标头:

<openerp>
    <data>
        <template id="custom_external_layout_header" inherit_id="report.external_layout_header">

        <!-- [...] -->    

        </template>
    </data>
</openerp>

【讨论】:

    【解决方案2】:

    将您的自定义标题放入&lt;div class="header"&gt;

    例如:

    <div class="header"> <span>hi</span> <div>

    【讨论】:

      【解决方案3】:
       1. sudo apt-get remove wkhtmltopdf --purge
       2. sudo wget
          https://downloads.wkhtmltopdf.org/0.12/0.12.1/wkhtmltox-0.12.1_linux-trusty-amd64.deb
       3. sudo dpkg -i wkhtmltox-0.12.1_linux-trusty-amd64.deb
       4. sudo cp /usr/local/bin/wkhtmltopdf /usr/bin
       5. sudo cp /usr/local/bin/wkhtmltoimage /usr/bin
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-10-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-03-25
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多