天天看點

odoo 報表列印多條記錄換頁與不換頁設定

主要看​

​web.basic_layout​

​​是在​

​foreach​

​ 之前還是之後

  1. basic_layout 在foreach 之前,沒有換頁
<template id="product_item_label">
        <t t-call="web.html_container">
            <t t-call="web.basic_layout">

            <t t-foreach="docs" t-as="doc">
                    <div class="page">
                        <t t-set="product" t-value="doc"/>
                        <t t-if="product.barcode">
                            <img alt="Barcode" t-if="len(product.barcode) == 13" t-att-src="'/report/barcode/?type=%s&value=%s&width=%s&height=%s' % ('EAN13', product.barcode, 600, 150)" style="width:100%;height:4rem;" />
                            <img alt="Barcode" t-elif="len(product.barcode) == 8" t-att-src="'/report/barcode/?type=%s&value=%s&width=%s&height=%s' % ('EAN8', product.barcode, 600, 150)" style="width:100%;height:4rem;" />
                            <img alt="Barcode" t-else="" t-att-src="'/report/barcode/?type=%s&value=%s&width=%s&height=%s' % ('Code128', product.barcode, 600, 150)" style="width:100%;height:4rem" />
                            <span t-field="product.barcode" />
                        </t>
                        <t t-else="">
                            <span class="text-muted">No barcode available</span>
                        </t>
                    </div>
                </t>
            </t>
        </t>
    </template>      
odoo 報表列印多條記錄換頁與不換頁設定
  1. base_layout 在foreach 裡邊,則每條記錄至少占用一頁.
<template id="product_item_label">
        <t t-call="web.html_container">

            <t t-foreach="docs" t-as="doc">
            <t t-call="web.basic_layout">

                    <div class="page">
                        <t t-set="product" t-value="doc"/>
                        <t t-if="product.barcode">
                            <img alt="Barcode" t-if="len(product.barcode) == 13" t-att-src="'/report/barcode/?type=%s&value=%s&width=%s&height=%s' % ('EAN13', product.barcode, 600, 150)" style="width:100%;height:4rem;" />
                            <img alt="Barcode" t-elif="len(product.barcode) == 8" t-att-src="'/report/barcode/?type=%s&value=%s&width=%s&height=%s' % ('EAN8', product.barcode, 600, 150)" style="width:100%;height:4rem;" />
                            <img alt="Barcode" t-else="" t-att-src="'/report/barcode/?type=%s&value=%s&width=%s&height=%s' % ('Code128', product.barcode, 600, 150)" style="width:100%;height:4rem" />
                            <span t-field="product.barcode" />
                        </t>
                        <t t-else="">
                            <span class="text-muted">No barcode available</span>
                        </t>
                    </div>
                </t>
            </t>
        </t>
    </template>      
odoo 報表列印多條記錄換頁與不換頁設定