【问题标题】:Qweb report in one page odoo 9在一页odoo 9中的Qweb报告
【发布时间】:2017-01-31 15:04:28
【问题描述】:

如何在 .xml 中定义在一页中显示数据(一个在另一个之下)。在我的示例中生成 qweb 后,数据显示在 4 个 pdf 页面上!

例子:

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

返回:[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>

如何定义foreach以在一个pdf文档中显示数据(thead + 4 row)

【问题讨论】:

    标签: report openerp qweb


    【解决方案1】:

    如果每条记录都是表中的一行,那么您可能需要更多类似的内容。

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

    【讨论】:

    • 干得好,Tnx 很多!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多