Search code examples
reportodooqweb

Qweb report in one page odoo 9


How define in .xml display data in one page (one below the other). After generate qweb in my example data is display on 4 pdf page!

Example:

datas = {
                 'ids': ids,
                 'model': 'my.model',
                 'form': data
                }
        return {
                'type': 'ir.actions.report.xml',
                'report_name': "my_module.my_report",
                'datas': datas,
            }

return: [1, 2, 3, 4]

.xml

<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="report_my_document">
    <t t-call="report.html_container">
          <t t-call="report.external_layout">
                <div class="page">
                    <table class="table table-condensed">
                        <thead>
                            <tr>
                                <th>Name</th>
                                <th>State</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td><t t-esc="o.name"/></td>
                                <td><t t-esc="o.state"/></td>
                            </tr>
                        </tbody>
                    </table>  
             </div>
        </t>
    </t>
</template>

<template id="report_my">
    <t t-call="report.html_container">
        <t t-foreach="docs" t-as="o">
            <t t-call="my_module.report_my_document"/>
        </t>
    </t>
</template>
</data>
</openerp>

How define foreach to display data in one pdf documen (thead + 4 row)?


Solution

  • If each record is a row in your table, you probably want something more like this.

    <template id="report_my_document">
        <t t-call="report.html_container">
              <t t-call="report.external_layout">
                    <div class="page">
                        <table class="table table-condensed">
                            <thead>
                                <tr>
                                    <th>Name</th>
                                    <th>State</th>
                                </tr>
                            </thead>
                            <tbody>
                                <t t-foreach="docs" t-as="o">
                                    <tr>
                                        <td><t t-esc="o.name"/></td>
                                        <td><t t-esc="o.state"/></td>
                                    </tr>
                                </t>
                            </tbody>
                        </table>  
                 </div>
            </t>
        </t>
    </template>
    
    <template id="report_my">
        <t t-call="report.html_container">
            <t t-call="my_module.report_my_document"/>
        </t>
    </template>