首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Odoo Qweb报告

Odoo Qweb报告
EN

Stack Overflow用户
提问于 2014-09-24 04:21:35
回答 1查看 8.6K关注 0票数 1

我正在使用qweb模板在Odoo中创建报告,当我编辑文件格式时,我没有得到想要的视图。

这是我的密码。

代码语言:javascript
复制
    <?xml version="1.0" encoding="UTF-8"?>
    <openerp>
    <data>
    <template id="leave_card_report_temp">
    <!--    <t t-call="report.html_container">-->
    <!--        <t t-foreach="docs" t-as="doc">-->
                <t t-call="report.external_layout">
                    <div class="page" style="width:860px;">
                      <!--<img t-if="company.logo" t-att-src="'data:image/png;base64,%s' % company.logo" style="max-height:60px;align:left"/>-->
                        <h3><p style="text-center;">Leave Card</p></h3>

                        <br/>    

                        <style>
                                table, th, td {
                                border: 2px solid black;

                                border-collapse: collapse;
                                }
                                th, td {
                                padding: 5px;
                                text-align: left;    
                                }
                        </style> 

                        <table style="width:860px;font-Size:11px; border:1px solid black;border-collapse:collapse;border-bottom:1px solid white;">
    <!--                      <t t-foreach="docs" t-as="doc">-->
    <!--                        <t t-if="o.name">-->
                            <tr> 

                               <td><strong>Name:</strong></td>
                               <td>

    <!--                               <span t-field="doc.name"/>-->

                               </td>

                                <td><strong>Designation:</strong></td>
    <!--                            <td><span t-field="designation"/></td>-->
                                <td><strong>Department:</strong></td>
    <!--                            <td><span t-field="department"/></td>-->
                                 <td><strong>Employee Code:</strong></td>
    <!--                            <td><span t-field="name"/></td>-->
                           </tr>
                           <tr> 
                           <td><strong>DOJ(C):</strong></td><td></td>
                           <td><strong>DOJ(R):</strong></td><td></td>
                           </tr>
    <!--                      </t>   -->

                        </table> 
                        <br/>
                        <br/>    
                        <table cellspacing="1" cellpadding="4" border="3" class = "table table-striped">
                          <!--<table style="width:860px;font-Size:11px; border:1px solid black;border-collapse:collapse;border-bottom:1px solid white;">-->
                            <tr>                       
                                <th width="70" rowspan="2" >DATE FROM</th>
                                <th width="70" rowspan="2" >DATE TO</th>
                                <th width="70" rowspan="2" >No Of Days</th>
                                <th colspan="3"> CL</th>
                                <th colspan="4"> EL</th>
                                <th width="70" rowspan="2">LOP</th>
                                <th colspan="2">INITIALS</th>
                                <th width="70" rowspan="2"> REMARKS</th>
                            </tr>

                            <tr align="right"> 
                                <th width="70">Earned</th>
                                <th width="70">Availed</th>
                                <th width="70">Balance</th>
                                <th width="70">Earned</th>
                                <th width="70">Availed</th>
                                <th width="70">Balance</th>
                                <th width="70">Encashment</th>
                                <th width="70">Reporting Officer</th>
                                <th width="70">Reviewing Officer</th>

                            </tr>   
                            <tbody>                               
                            <t t-foreach = "docs" t-as = "doc">
                            <tr>

                                <td><span t-field="doc.date_from"/></td>
                                <td><span t-field="doc.date_to"/></td>
                                <td><span t-field="doc.no_of_days"/></td>
                                <td><span t-field = "doc.earned_cl"/></td>
                                <td><span t-field = "doc.availed_cl"/></td>
                                <td><span t-field = "doc.balance_cl"/></td>
                                <td><span t-field = "doc.earned_el"/></td>
                                <td><span t-field = "doc.availed_el"/></td>
                                <td><span t-field = "doc.balance_el"/></td>
                                <td><span t-field = "doc.encash"/></td>
                                <td><span t-field = "doc.loss_of_pay"/></td>
                                <td><span t-field = "doc.reporting_officer"/></td>
                                <td><span t-field = "doc.reviewing_officer"/></td>
                                <td><span t-field = "doc.remark"/></td>   
                            </tr>
                            </t>
                            </tbody>
                          </table>



                    </div>

           </t>
    <!--        </t>-->
    <!--    </t>-->
    </template>
    <template id="leave_card_view">
        <t t-call="report.html_container">
            <t t-foreach="doc_ids" t-as="doc_id">
                <t t-raw="translate_doc(doc_id, doc_model, 'leaves_management.leave_card_report_temp')"/>
            </t>
        </t>
    </template>

    </data>
    </openerp>

我的问题是,当我试图打印一份报告时,我会得到多个文件。在我的第一个表中,如果我分配值doc.name,它的创建问题

我喜欢在我的第二个表中有多个记录,但是对于我的第一个表,它应该显示那些记录。

EN

回答 1

Stack Overflow用户

发布于 2014-10-12 09:12:40

首先,您应该将docs对象放在全局对象中,模板在QWeb报告中运行,如下所示。

代码语言:javascript
复制
<template id="leave_card_report_temp">
    <t t-call="report.html_container">
    <t t-foreach="docs" t-as="doc">
And access the doc in multiple table in ODOO
<table>
    <tr>
        <td>
        <t t-if="doc.name>
            <span t-field="doc.name"/>
        </t>
        </td>
    </tr>
    </table>   
    <table>
    <tr>
        <td>
        <t-if="doc.date_from">
            <span t-field="doc.date_from"/>
        </t>
        </td>
        <td>
        <t-if="doc.date_to">    
            <span t-field="doc.date_to"/>
        </t>  
        </td>
        <td>
        <t-if="doc.no_of_days">    
            <span t-field="doc.no_of_days"/>
        </t>  
       </td>
    </tr>
    </table>
</t>
</t>
</template>

这可能对你有帮助

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26008505

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档