2

我被要求在 Odoo 14 中为采购订单开发自定义报告。

此报告的标题必须在所有页面中。在第一页中,表格显示在良好的位置,但在第二页上,标题位于表格标题之上。看图片:

第一页: 第一页页眉 第二页: 第二页页眉

模板代码是这样定义的:

<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <template id="report_purchaseorder" inherit_id="purchase.report_purchaseorder">
        <xpath expr="//t[@t-call='purchase.report_purchaseorder_document']" position="replace">
            <div class="header" t-att-style="report_header_style" style="font-family:Arial, Helvetica, sans-serif;">
                <div class="row" style="margin-left:8px; margin-right:8px;">
                    <t t-if="not o and doc">
                        <t t-set="o" t-value="doc"/>
                    </t>

                    <t t-if="o and 'company_id' in o">
                        <t t-set="company" t-value="o.company_id.sudo()"/>
                    </t>
                    <t t-if="not o or not 'company_id' in o">
                        <t t-set="company" t-value="res_company"/>
                    </t>
                    
                </div>
                <div class="row" style="margin-left:8px; margin-right:8px;">
                        <table class="table" style="margin-top:-30px !important; ">
                            <tbody>
                                <tr>
                                    <td style="padding:0px !important;">
                                        <div style="text-align:justify; font-size:10px;">
                                            <p style="float:left;">
                                                <span><strong>Señores:</strong></span> <br/>
                                                
                                                <span><strong>Atención:</strong></span>
                                                
                                                <span t-field="o.partner_id.name"/><br/>
                                                
                                                <span><strong>Dirección:</strong></span>
                                                
                                                <span t-field="o.partner_id.city"/><br/>
                                                
                                                <span><strong>Teléfonos:</strong></span>
                                                
                                                <span t-field="o.partner_id.phone"/><br/>
                                                
                                                <span><strong>Email:</strong></span>
                                                
                                                <span t-field="o.partner_id.email"/><br/>
                                                
                                                <span><strong>Atendido por:</strong></span>
                                                &#160;&#160;&#160;&#160;&#160;
                                                <span t-field="o.user_id.name"/>
                                                
                                                <i class="fa fa-phone" role="img" aria-label="Phone" title="Phone"/><span t-field="o.user_id.phone"/>
                                                
                                                <i class="far fa-envelope" role="img" aria-label="Email" title="Email"/>&#160;&#160;<span t-field="o.user_id.email"/>
                                            </p>
                                        </div>
                                    </td>
                                    <td style="padding:0px !important; width:30%;">
                                        <div style="text-align:justify; font-size:10px; padding-left:40%;">
                                            <p style="float:left;">
                                                <span><strong>N° de Página:</strong></span> <span class="page"/> de <span class="topage"/><br/>
                                                
                                                <span><strong>Cotización N°:</strong></span>
                                                <span t-field="o.name"/> <br/>
                                                
                                                <span><strong>F. de Emisión:</strong></span>
                                                <span t-field="o.create_date" t-options='{"widget": "date"}'/> <br/>
                                                
                                                <span><strong>Vigente Hasta:</strong></span>
                                                <span t-field="o.date_order" t-options='{"widget": "date"}'/>
                                                <br/>
                                                <span><strong>Condic. Pago:</strong></span>
                                            </p>
                                        </div>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            <t t-call="web.external_layout">
                <div class="page" style="font-family:Arial, Helvetica, sans-serif;">
                    <div class="row" style="margin-top:10px; min-width:100px;">
                        <table class="table" style="text-align:left; font-size:10px; ">
                            <thead>
                                <tr>
                                    <th class="text-center">Imagen</th>
                                    <th class="text-center">Código</th>
                                    <th class="text-center">Descripción</th>
                                    <th class="text-center">Cant.</th>
                                    <th class="text-center">Precio U.</th>
                                    <th class="text-center">Desc.</th>
                                    <th class="text-center">Total Neto</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr t-foreach="o.order_line" t-as="line">
                                    <div>
                                        <td class="text-center"><img t-if="line.product_id.image_1920" t-att-src="'data:image/png;base64,%s' % to_text(line.product_id.image_1920)" style="max-height: 80px;width: 100px;margin: auto;"/></td>
                                        <td class="text-center"><span t-field="line.product_id.default_code"/></td>
                                        <td class="text-center" ><span t-field="line.name"/></td>
                                        <td class="text-center">
                                            <span t-field="line.product_qty"/>
                                            <span t-field="line.product_uom.name" groups="uom.group_uom"/>
                                        </td>
                                        <td class="text-right" ><span t-field="line.price_unit"/></td>
                                        <td class="text-right" ></td>
                                        <td class="text-right" >
                                            <span t-field="line.price_subtotal" t-options='{"widget": "monetary", "display_currency": o.currency_id}'/>
                                        </td>
                                    </div>
                                </tr>
                                <tr>
                                    <td class="text-right">
                                        <br/>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
                    
             
            </t>
        </xpath>
    </template>
</odoo>

我尝试使用 CSS 中的填充或边距属性,但如果我使用它,它也会从第一页移动表格。

4

1 回答 1

1
<record id="paperformat_euro" model="report.paperformat">
        <field name="name">European A4</field>
        <field name="default" eval="True" />
        <field name="format">A4</field>
        <field name="page_height">0</field>
        <field name="page_width">0</field>
        <field name="orientation">Portrait</field>
        <field name="margin_top">0</field>
        <field name="margin_bottom">23</field>
        <field name="margin_left">7</field>
        <field name="margin_right">7</field>
        <field name="header_line" eval="False" />
        <field name="header_spacing">35</field>
        <field name="dpi">90</field>
    </record>    
于 2021-05-26T16:40:22.563 回答