1. 程式人生 > >odoo對list多選分頁列印問題

odoo對list多選分頁列印問題

1.先將單頁列印的模板寫好,注意:在單模板<div>中加入class=‘page’。程式碼如下(自行忽略css未寫成class):

<template id="report_lot_barcode_template">
       <!--<t t-call="report.html_container">-->
         <!--<t t-call="report.external_layout">-->
           <div class="page">
        <div class="col-xs-8" style="padding:0;">
               <table style="border-spacing:0;margin-bottom:0;height:122px;" class="table">
                   <!--<thead>-->
                   <!--</thead>-->
                   <tbody style="text-align:center">
                       <tr style="width: 1in;">
                           <td colspan="8" style="border: 2px solid black; text-align: center;">
                               <img src="/stock_report/static/src/jpg/xxxx.jpg" width="80" height="25"/>
                           </td>
                           <td colspan="2" style="border: 2px solid black; text-align: center;">
                               xxx
                           </td>
                           <td colspan="3" style="border: 2px solid black; text-align: center;" t-esc="doc.remark_one">
                           </td>
                       </tr>
                       <tr style="width: 1in;">
                           <td colspan="3" style="border: 2px solid black; text-align: center;vertical-align: middle;">xxx</td>
                           <td colspan="5" style="border: 2px solid black; text-align: center;vertical-align: middle;" t-esc="doc.product_id.name"></td>
                           <td colspan="5" style="border: 2px solid black; text-align: center;">
                               <img t-if="doc.product_id.name" t-att-src="'/report/barcode/?type=%s&amp;value=%s&amp;width=%s&amp;height=%s' % ('QR', doc.product_id.name, 200, 200)" style="width:100%;height:100%;"/>
                           </td>
                       </tr>
                       <tr style="width: 1in;">
                           <td colspan="3" style="border: 2px solid black; text-align: center;">xxx</td>
                           <td colspan="2" style="border-right:0px;border-top:1px" t-esc="doc.ref"></td>
                           <td colspan="3" style="border-left:0px;border-top:1px">
                               <img t-if="doc.lot_id" t-att-src="'/report/barcode/?type=%s&amp;value=%s&amp;width=%s&amp;height=%s' % ('EAN13', doc.lot_id.name, 600, 150)" style="width:100%;height:20%;"/>
                           </td>
                           <td colspan="2" style="border: 2px solid black; text-align: center;">xx</td>
                           <td colspan="3" style="border: 2px solid black; text-align: center;" t-esc="doc.lot_uom_ratio"></td>
                       </tr>
                       <tr>
                           <td colspan="3" style="border: 2px solid black; text-align: center;">xx</td>
                           <td colspan="5" style="border: 2px solid black; text-align: center;" >
                               <t t-if="doc.lot_lenth" t-esc="doc.lot_lenth"></t>
                               <t t-else=""><span></span></t>
                           </td>
                           <td colspan="5" rowspan="3" style="border: 2px solid black; text-align: center;">
                               <img src="/product_barcode/static/src/jpg/circle.png" width="90" height="90"/>
                           </td>
                       </tr>
                       <tr style="width: 1in;">
                           <td colspan="3" style="border: 2px solid black; text-align: center;">xxx</td>
                           <td colspan="5" style="border: 2px solid black; text-align: center;" t-esc="doc.lot_uom_qty and doc.lot_uom.name"></td>
                           <td colspan="5"/>
                       </tr>
                       <tr style="width: 1in;">
                           <td colspan="3" style="border: 2px solid black; text-align: center;">xxx</td>
                           <td colspan="5" style="border: 2px solid black; text-align: center;" t-esc="doc.code"></td>
                           <td colspan="5"/>
                       </tr>
                       <tr style="width: 1in;">
                           <td colspan="3" style="border: 2px solid black; text-align: center;">xxxx</td>
                           <td colspan="5" style="border: 2px solid black; text-align: center;" t-esc="doc.board_number"></td>
                           <td colspan="5" style="border: 2px solid black; text-align: center;">
                               <img t-if="doc.board_number" t-att-src="'/report/barcode/?type=%s&amp;value=%s&amp;width=%s&amp;height=%s' % ('Code128', doc.lot_lenth, 600, 150)" style="width:100%;height:20%;"/>
                           </td>
                       </tr>
                   </tbody>
               </table>
        </div>
           </div>
         <!--</t>-->
       <!--</t>-->
    </template>

2.新建模板,使用t-foreach="docs"呼叫單模板即可,程式碼如下:

<template id="report_lot_barcode_templates">
        <t t-call="report.html_container">
            <div>
                <t t-foreach="docs" t-as="doc">
                    <t t-call="product_barcode.report_lot_barcode_template"></t>
                </t>
            </div>
        </t>
    </template>