【问题标题】:More space is coming between Header and Page1 but from page2 it is correctHeader 和 Page1 之间有更多空间,但从 page2 开始是正确的
【发布时间】:2020-02-11 05:19:23
【问题描述】:

我尝试使用自定义纸张格式创建 QWEB 报告,但页眉和第 1 页之间有更多空间,但从第 2 页开始它是正确的。我尝试调整 Margin TopHeader Spacing。 提前致谢

页面格式

<record id="paper_xn_so_preprint" model="report.paperformat">
    <field name="name">Sale Order PrePrint</field>
    <field name="default" eval="True"/>
    <field name="format">custom</field> 
    <field name="page_height">148</field>
    <field name="page_width">210</field>
    <field name="orientation">Portrait</field>
    <field name="margin_top">50</field>
    <field name="margin_bottom">14</field>
    <field name="margin_left">0</field>
    <field name="margin_right">0</field>
    <field name="header_line" eval="False"/>
    <field name="header_spacing">20</field>
    <field name="dpi">90</field>
</record>

模板示例

<template id="xn_saleorder_preprint">
    <!-- <t t-call="report.html_container"> -->
    <t t-foreach="docs" t-as="o">
        <div class="header">
            <div class="row col-xs-12">
                <div class="col-xs-4">
                    Customer
                    ID
                    Mobile
                </div>
                <div class="col-xs-4">
                    Sale Order
                </div>
                <div class="col-xs-4 pull-right">
                    Order Date
                    Delivery Date
                    SO Number
                </div>
            </div>
        </div>
        <div class="page">
            Page Contents
        </div>
    </t>
</template>

编辑

我认为问题是由表引起的。但无法弄清楚问题出在哪里。

代码

<div class="page">
    <table width="100%">
        <thead>
            <th>Sl No.</th>
            <th>Customer</th>
            <th>Product</th>
            <th>Quantity</th>
            <th">Unit Price</th>
            <th>Taxes</th>
            <th>Discount</th>
            <th>Subtotal</th>
        </thead>
        <tbody>
            <t t-set="sl_no" t-value="0"/>
            <tr t-foreach="o.order_line" t-as="line">
                <t t-set="sl_no" t-value="sl_no+1"/>
                <td><span t-esc="sl_no"/></td><br/>
                <td><span t-field="line.xn_order_customer_name"/></td>
                <td><span t-field="line.product_id.name"/></td>
                <td class="text-right">
                    <t t-if = "float(line.product_uom_qty.is_integer())">
                        <span t-esc = "int(line.product_uom_qty)" />
                    </t>
                    <t t-if = "not float(line.product_uom_qty.is_integer())" >
                        <span t-field = "line.product_uom_qty" />
                    </t>
                </td>
                <td class="text-right"><span t-field="line.price_unit"/></td>
                <td class="text-right">
                    <t t-set="vat_amount" t-value="0"/>
                    <t t-foreach="line.tax_id" t-as="x">
                        <t t-set="vat_amount" t-value="vat_amount+(line.price_subtotal*x.amount/100)"/>
                    </t>
                    <span t-esc="vat_amount" t-options="{'widget': 'float', 'precision': 2}"/>
                </td>
                <td class="text-right"><span t-field="line.xn_discount_amt" t-options="{'widget': 'float', 'precision': 2}"/></td>
                <td class="text-right"><span t-field="line.price_subtotal"/></td>
            </tr>
        </tbody>
    </table>
</div>

【问题讨论】:

    标签: xml odoo odoo-10 qweb


    【解决方案1】:

    您可以尝试以下方法:

    <field name="margin_top">10</field>
    

    编辑:

    您可以试试web.html_containerweb.external_layout 模板。

    <template id="template_xn_saleorder_preprint">
        <t t-call="web.external_layout">
            <div class="header">
                <div class="row col-xs-12">
                    <div class="col-xs-4">
                        Customer
                        ID
                        Mobile
                    </div>
                    <div class="col-xs-4">
                        Sale Order
                    </div>
                    <div class="col-xs-4 pull-right">
                        Order Date
                        Delivery Date
                        SO Number
                    </div>
                </div>
            </div>
            <div class="page">
                Page Contents
            </div>
        </t>
    </template>
    
    
    <template id="xn_saleorder_preprint">
        <t t-call="web.html_container">
            <t t-foreach="docs" t-as="o">
                <t t-call="template_xn_saleorder_preprint"/>
            </t>
        </t>
    </template>
    

    编辑:

    这是因为这段代码: &lt;td&gt;&lt;span t-esc="sl_no"/&gt;&lt;/td&gt;&lt;br/&gt;

    【讨论】:

    • 嗨..!!试过这个。使用这个时,标题部分被部分切断。
    • @vbt 我已经编辑了我的答案。你可以试试那个。
    • report. 代替web. 尝试了这个,因为它是odoo10 但结果还是一样。
    • 如何减小标题间距?
    • 兄弟..我认为是因为表格..将很快更新代码..首先尝试放置整个代码但堆栈溢出不允许低解释。
    猜你喜欢
    • 1970-01-01
    • 2021-12-28
    • 1970-01-01
    • 1970-01-01
    • 2020-10-17
    • 1970-01-01
    • 1970-01-01
    • 2012-03-12
    • 2023-03-30
    相关资源
    最近更新 更多