首页 文章

在qweb odoo报告中添加一行

提问于
浏览
1

我有一个qweb报告,其中我想添加一行,其中包含报告的每个cols的总数:这是我的qweb代码;它关于创建一个工资单报告,它包含11个cols,我想用cols添加一行总计

<data>
<t t-call="report.html_container">
    <t t-foreach="docs" t-as="o">
        <t t-call="report.external_layout">
            <div class="page" >
                <br></br><br></br>
                <div class="row" style="border: 1px solid black">
                    <div class="col-md-12 text-center"><h2>JOURNAL DE PAIE</h2></div>
                    <div class="col-md-12 text-center"><p>Période du <span t-esc="data['form']['date_start']"/> au <span t-esc="data['form']['date_end']"/></p></div>
                </div>
                <br></br><br></br>
                <div class="row">
                <table class="table table-striped table-bordered table-condensed table-hover" >
                        <thead><!-- table head-->
                            <tr style="background-color: #BEC5C0;">
                                <th>Periode</th>
                                <th>Matricule</th>
                                <th>Employé</th>
                                <th>BASE</th>
                                <th>Primes</th>
                                <th>BRUT</th>
                                <th>CNSS</th>
                                <th>SAL IMPO</th>
                                <th>IRPP</th>
                                <th>Avance/pret</th>
                                <th>NET A PAYER</th>

                             </tr>
                      </thead>
                    <tbody>
                        <tr  t-foreach="get_all_payslip_per_period(data['form']['date_start'],data['form']['date_end'])" t-as="p" >
                                <td style="text-align:center;" t-esc="get_month_name(p.date_from)"></td>
                                <td t-esc="p.employee_id.id"></td>
                                <td t-esc="p.employee_id.name"></td> 
                                <t t-foreach="get_payslip_lines(p.line_ids)" t-as="l">
                                   <t t-if="l.code=='BASE'">
                                        <t t-set="base" t-value="l.total"/>
                                        <td t-esc="base"></td> 
                                    </t>
                                    </t>
                                    <!-- primes -->
                                    <td>
                                            <div t-foreach="get_primes_values(p)" t-as="pr" >
                                                <div style="text-align:left;background-color: #BEC5C0;" t-esc="pr['code']"></div>
                                                <div style="text-align:right;background-color:#CDD8D0;"  t-esc="pr['val']"></div>                                                   
                                            </div>

                                    </td>
                                <t t-foreach="get_payslip_lines(p.line_ids)" t-as="l">
                                <t t-if="l.code=='BRUT' ">
                                        <t t-set="brut" t-value="l.total"/>
                                        <td t-esc="brut"></td> 
                                    </t>


                                    <t t-if="l.code=='CNSS' ">
                                        <t t-set="cnss" t-value="l.total"/>
                                        <td t-esc="cnss"></td> 
                                    </t> 


                                     <t t-if="l.code=='NET' ">
                                        <t t-set="net" t-value="l.total"/>
                                        <td t-esc="net"></td> 
                                    </t> 


                                    <t t-if="l.code=='IRPP' ">
                                        <t t-set="irpp" t-value="l.total"/>
                                        <td t-esc="irpp"></td>       
                                    </t> 

                                </t>
                                    <td t-esc="p.avance_amount"></td>


                                    <td t-esc="get_total_by_rule_category(p, 'AUTRE')-get_total_by_rule_category(p, 'RCC')-(p.avance_amount)"></td>


                        </tr>
                </tbody> 
                </table>


                </div>
            </div>
        </t>
    </t>
</t>
</data>

1 回答

  • 1

    试试这个:

    <t t-set="brut" t-value="0"/> <!-- initialize the variable-->
    <t t-foreach="get_payslip_lines(p.line_ids)" t-as="l">
        <t t-if="l.code=='BRUT' ">
            <t t-set="brut" t-value="brut + l.total"/>
         </t>
    </t>
    <td t-esc="brut"></td> <!-- To show it on the report-->
    

    在以下情况下初始化变量:

    <tr  t-foreach="get_all_payslip_per_period(data['form']['date_start'],data['form']['date_end'])" t-as="p" >
    

    在添加包含总计的新 tr 之前加总:

    </tr>
        <tr>
            <td><t t-esc='Total1'/></td>
            ...
        </tr>
    </tbody>
    

相关问题