自定义报告布局 odoo 10

Customize report layout odoo 10

我自定义 external_layout_header 以在 Purchase Order 中重复 vendor&shipping address。它的成功得到了充分体现。但问题是,div class='page' 中的内容与 header 重叠。我把 margin-top:xx 给了 class='page' 但它没有受到影响。我怎样才能做到这一点?

*external_layout_inherit.xml

<template id="purchase_extrenal_layout" inherit_id="report.external_layout_header">
     <xpath expr="//div[@class='row zero_min_height']" position="before">
     <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="" style="float:left; text-align:left; margin-left:50px;">
        <strong>Customer address:</strong>
          <div t-field="o.partner_id"
              t-options='{"widget": "contact", "fields": ["address", "name", "phone", "fax"], "no_marker": True, "phone_icons": True}'/>
              <p t-if="o.partner_id.vat">VAT: <span t-field="o.partner_id.vat"/></p>
      </div>
      <div style="float:right; text-align:right; margin-right:50px;">
        <strong>Shipping address:</strong>
        <div t-if="o.dest_address_id">
            <div t-field="o.dest_address_id"
                t-options='{"widget": "contact", "fields": ["address", "name", "phone", "fax"], "no_marker": True, "phone_icons": True}'/>
        </div>

        <div t-if="not o.dest_address_id and o.picking_type_id and o.picking_type_id.default_location_dest_id">
            <span t-field="o.picking_type_id.default_location_dest_id.partner_id.name"/>
            <div t-field="o.picking_type_id.default_location_dest_id.partner_id"
                t-options='{"widget": "contact", "fields": ["address", "phone", "fax"], "no_marker": True, "phone_icons": True}'/>
        </div>
      </div>
</div>

样本报告。

页眉和页脚"margins"以文档纸张格式设置。因此,您必须更改默认的纸张格式,这应该用于 Odoo 中的大多数报告,或者您创建一个新格式并将其 link 用于采购订单报告。

将此添加到您的报告文件中。

<record id="paperformat_rfq" model="report.paperformat">
    <field name="name">A4 Barcode Paper</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">8</field>
    <field name="margin_bottom">0</field>
    <field name="margin_left">3</field>
    <field name="margin_right">0</field>
    <field name="header_line" eval="False"/>
    <field name="header_spacing">5</field>
    <field name="dpi">90</field>
</record>

<record id="action_request_quotation" model="ir.actions.report.xml">
    <field name="paperformat_id" ref="your_module_name.paperformat_rfq"/>
</record>

根据需要调整margin_top和header_spacing。