southernegro
southernegro

Reputation: 394

Report header is overlapsing table from page content

I've been ask to develop a custom report for purchase orders in Odoo 14.

The header of this report has to be in all pages. In the first page the table is displayed in good position, but on second page, the header is over the table headers. Look at the pictures:

First page: First page header Second page: Second page header

Template code is defined in this way:

<?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>

I've tried using padding or margin attributes from CSS, but if I use it, it moves the table from first page also.

Upvotes: 2

Views: 1355

Answers (1)

Sakthi Priya
Sakthi Priya

Reputation: 337

<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>    

Upvotes: 2

Related Questions