콘텐츠로 건너뛰기
메뉴
신고된 질문입니다
5 답글
2978 화면

How can I get the  subtotal per page of the records.?

I need your help. Thank you!

아바타
취소

Could you plz elaborate your query

작성자

here is my code

<?xml version="1.0" encoding="UTF-8" ?>

<odoo>

<data>

<!--Loan Summary Template-->

<template id="report_loan_summary_template">

<t t-call="report.html_container">

<!--<t t-call="report.external_layout"/>-->

<t t-foreach="docs" t-as="o">

<div class="page">

<!--<br/><br/><br/><br/>-->

<t t-set="company_ids" t-value="[]"/>

<t t-foreach="records.sorted(key=lambda r: r.employee_id.company_id.name)" t-as="recs">

<t t-set="company_ids" t-value="company_ids+[recs.employee_id.company_id]"/>

</t>

<t t-foreach="o.get_sorted(list(set(company_ids)))" t-as="company">

<div style="page-break-before:always;">

<t t-if="o.columns_of_two">

<t t-set="end" t-value="[1,2]"/>

</t>

<t t-if="not o.columns_of_two">

<t t-set="end" t-value="[1]"/>

</t>

<t t-foreach="end" t-as="e">

<div class="col-xs-6">

<!--<div class="text-center">-->

<!--<span style="font-weight:bold;font-family:Liberation Sans;font-size:16px;"><span class="text-uppercase" t-field="o.loan_type_id.name"/> SUMMARY<br/></span>-->

<!--&lt;!&ndash;<span style="font-weight:bold;font-family:Liberation Sans;font-size:16px;">LOAN SUMMARY LIST<br/></span>&ndash;&gt;-->

<!--<span style="font-weight:bold;font-family:Liberation Sans;font-size:10px;">FOR THE MONTH OF <span class="text-uppercase" t-esc="time.strftime('%B', time.strptime(o.from_date,'%Y-%m-%d'))"/><br/></span>-->

<!--&lt;!&ndash;<span><span t-esc="time.strftime('%B %d, %Y', time.strptime(o.from_date,'%Y-%m-%d'))"/> - <span t-esc="time.strftime('%B %d, %Y', time.strptime(o.to_date,'%Y-%m-%d'))"/></span>&ndash;&gt;-->

<!--</div><br/>-->

<!--<span style="font-weight:bold;font-family:Liberation Sans;font-size:12px;text-align:center;">Date: <span t-esc="context_timestamp(datetime.datetime.now()).strftime('%B %d, %Y %I:%M:%S %p')"/></span><br/>-->

<!--<t t-set="loan_type_ids" t-value="[]"/>-->

<!--<t t-foreach="records.sorted(key=lambda r: r.loan_type.name)" t-as="recs">-->

<!--<t t-set="loan_type_ids" t-value="loan_type_ids+[recs.loan_type]"/>-->

<!--</t>-->

<!--<t t-foreach="o.get_sorted(list(set(loan_type_ids)))" t-as="loan">-->

<!--<span style="font-weight:bold;font-family:Liberation Sans;font-size:14px;" class="text-uppercase"><span t-esc="loan.name"/></span><br/>-->

<table style="width:100%;text-align:center;font-family:Liberation Sans;border-collapse: collapse;">

<thead>

<tr>

<th colspan="5" style="width:100%;padding:8px;text-align:center;vertical-align:center;">

<div class="text-center">

<span style=";font-family:Liberation Sans;font-size:16px;" class="text-uppercase" t-esc="company.name"/><br/>

<span style="font-weight:bold;font-family:Liberation Sans;font-size:16px;"><span class="text-uppercase" t-field="o.loan_type_id.name"/> SUMMARY<br/></span>

<span style="font-weight:bold;font-family:Liberation Sans;font-size:10px;">FOR THE MONTH OF <span class="text-uppercase" t-esc="time.strftime('%B, %Y', time.strptime(o.from_date,'%Y-%m-%d'))"/><br/></span>

</div>

</th>

</tr>

<tr style="font-size:12;font-weight:bold;background-color:#d6d8db;text-align:center;border: 1px solid #000000;">

<th style="width:5%;padding:8px;text-align:center;vertical-align:center;border: 1px solid #000000;">ID NO.</th>

<th style="width:30%;padding:8px;text-align:center;vertical-align:center;border: 1px solid #000000;">EMPLOYEE'S NAME</th>

<th style="width:5%;padding:8px;text-align:center;vertical-align:center;border: 1px solid #000000;">15TH</th>

<th style="width:5%;padding:8px;text-align:center;vertical-align:center;border: 1px solid #000000;"><span t-esc="o.get_last_day_month(o.to_date)"/> </th>

<th style="width:5%;padding:8px;text-align:center;vertical-align:center;border: 1px solid #000000;">TOTAL</th>

</tr>

</thead>

<!--<t t-foreach="records.sorted(key=lambda r: r.employee_id.name)" t-as="rec">-->

<t t-set="employee_ids" t-value="[]"/>

<t t-foreach="records.sorted(key=lambda r: r.loan_id.employee_id)" t-as="recs">

<t t-if="recs.loan_id.employee_id.company_id.id == company.id">

<t t-set="employee_ids" t-value="employee_ids+[recs.loan_id.employee_id]"/>

</t>

</t>

<t t-foreach="o.get_sorted(list(set(employee_ids)))" t-as="employee">

<tbody>

<tr style="font-size:12px;">

<t t-set="loan_1" t-value="0"/>

<t t-set="loan_2" t-value="0"/>

<td style="width:5%;padding:8px;text-align:left;vertical-align:center;">

<span class="text-uppercase"><span t-esc="employee.identification_id"/></span>

</td>

<td style="width:30%;padding:8px;text-align:left;vertical-align:center;">

<span t-esc="employee.name"/>

</td>

<td style="width:5%;padding:8px;text-align:center;vertical-align:center;">

<t t-set="loan_1" t-value="0"/>

<t t-set="loan_1" t-value="sum([rec.paid_amount for rec in records if rec.loan_id.employee_id.id == employee.id and rec.loan_type_id.id == o.loan_type_id.id and rec.payroll_id.payslip_run_id.hr_period_id.vale_period == 1])"/>

<t t-esc="'{0:,.2f}'.format((loan_1))"/>

</td>

<td style="width:5%;padding:8px;text-align:center;vertical-align:center;">

<t t-set="loan_2" t-value="0"/>

<t t-set="loan_2" t-value="sum([rec.paid_amount for rec in records if rec.loan_id.employee_id.id == employee.id and rec.loan_type_id.id == o.loan_type_id.id and rec.payroll_id.payslip_run_id.hr_period_id.vale_period == 2])"/>

<t t-esc="'{0:,.2f}'.format((loan_2))"/>

</td>

<td style="width:5%;padding:8px;text-align:right;vertical-align:center;">

<span t-esc="'{0:,.2f}'.format(loan_2 + loan_1)"/>

</td>

</tr>

</tbody>

</t>

<tr>

<t t-set="total_loan_1" t-value="0"/>

<t t-set="total_loan_2" t-value="0"/>

<td style="vertical-align:center;text-align:center;padding:5px;border: 1px solid #000000;" colspan="2">

<strong><span>GRAND TOTAL</span></strong>

</td>

<td style="vertical-align:center;text-align:right;padding:5px;font-weight:bold;border: 1px solid #000000;">

<t t-set="total_loan_1" t-value="0"/>

<t t-set="total_loan_1" t-value="sum([rec.paid_amount for rec in records if rec.loan_type_id.id == o.loan_type_id.id and rec.payroll_id.payslip_run_id.hr_period_id.vale_period == 1])"/>

<t t-esc="'{0:,.2f}'.format((total_loan_1))"/>

</td>

<td style="vertical-align:center;text-align:right;padding:5px;font-weight:bold;border: 1px solid #000000;">

<t t-set="total_loan_2" t-value="0"/>

<t t-set="total_loan_2" t-value="sum([rec.paid_amount for rec in records if rec.loan_type_id.id == o.loan_type_id.id and rec.payroll_id.payslip_run_id.hr_period_id.vale_period == 2])"/>

<t t-esc="'{0:,.2f}'.format((total_loan_2))"/>

</td>

<td style="vertical-align:center;text-align:right;padding:5px;font-weight:bold;border: 1px solid #000000;">

<t t-esc="'{0:,.2f}'.format((total_loan_1 + total_loan_2))"/>

</td>

</tr>

</table><br/>

</div>

</t>

</div>

</t>

</div>

<div class="footer">

<i>

<div class="text-left">

<span style="font-size:12px;"><i>Date printed: <span t-esc="context_timestamp(datetime.datetime.now()).strftime('%B %d, %Y %I:%M:%S %p')"/></i></span>

</div>

<div class="text-center">

<ul class="list-inline">

<li>Page:</li>

<li><span class="page"/></li>

<li>/</li>

<li><span class="topage"/></li>

</ul>

</div>

</i>

</div>

</t>

</t>

</template>

</data>

</odoo>

베스트 답변

Hello SOUJIRO30,

is this a qweb report?

i think you need a "for-loop" inside of qweb, and you should know what object inside that page and get the data.

you can add multiple 




아바타
취소
베스트 답변

Hi, 

In order to help you, could you give us more details about your problem?

아바타
취소
작성자

here is my code, I hope you can help me.

<?xml version="1.0" encoding="UTF-8" ?>

<odoo>

<data>

<!--Loan Summary Template-->

<template id="report_loan_summary_template">

<t t-call="report.html_container">

<!--<t t-call="report.external_layout"/>-->

<t t-foreach="docs" t-as="o">

<div class="page">

<!--<br/><br/><br/><br/>-->

<t t-set="company_ids" t-value="[]"/>

<t t-foreach="records.sorted(key=lambda r: r.employee_id.company_id.name)" t-as="recs">

<t t-set="company_ids" t-value="company_ids+[recs.employee_id.company_id]"/>

</t>

<t t-foreach="o.get_sorted(list(set(company_ids)))" t-as="company">

<div style="page-break-before:always;">

<t t-if="o.columns_of_two">

<t t-set="end" t-value="[1,2]"/>

</t>

<t t-if="not o.columns_of_two">

<t t-set="end" t-value="[1]"/>

</t>

<t t-foreach="end" t-as="e">

<div class="col-xs-6">

<!--<div class="text-center">-->

<!--<span style="font-weight:bold;font-family:Liberation Sans;font-size:16px;"><span class="text-uppercase" t-field="o.loan_type_id.name"/> SUMMARY<br/></span>-->

<!--&lt;!&ndash;<span style="font-weight:bold;font-family:Liberation Sans;font-size:16px;">LOAN SUMMARY LIST<br/></span>&ndash;&gt;-->

<!--<span style="font-weight:bold;font-family:Liberation Sans;font-size:10px;">FOR THE MONTH OF <span class="text-uppercase" t-esc="time.strftime('%B', time.strptime(o.from_date,'%Y-%m-%d'))"/><br/></span>-->

<!--&lt;!&ndash;<span><span t-esc="time.strftime('%B %d, %Y', time.strptime(o.from_date,'%Y-%m-%d'))"/> - <span t-esc="time.strftime('%B %d, %Y', time.strptime(o.to_date,'%Y-%m-%d'))"/></span>&ndash;&gt;-->

<!--</div><br/>-->

<!--<span style="font-weight:bold;font-family:Liberation Sans;font-size:12px;text-align:center;">Date: <span t-esc="context_timestamp(datetime.datetime.now()).strftime('%B %d, %Y %I:%M:%S %p')"/></span><br/>-->

<!--<t t-set="loan_type_ids" t-value="[]"/>-->

<!--<t t-foreach="records.sorted(key=lambda r: r.loan_type.name)" t-as="recs">-->

<!--<t t-set="loan_type_ids" t-value="loan_type_ids+[recs.loan_type]"/>-->

<!--</t>-->

<!--<t t-foreach="o.get_sorted(list(set(loan_type_ids)))" t-as="loan">-->

<!--<span style="font-weight:bold;font-family:Liberation Sans;font-size:14px;" class="text-uppercase"><span t-esc="loan.name"/></span><br/>-->

<table style="width:100%;text-align:center;font-family:Liberation Sans;border-collapse: collapse;">

<thead>

<tr>

<th colspan="5" style="width:100%;padding:8px;text-align:center;vertical-align:center;">

<div class="text-center">

<span style=";font-family:Liberation Sans;font-size:16px;" class="text-uppercase" t-esc="company.name"/><br/>

<span style="font-weight:bold;font-family:Liberation Sans;font-size:16px;"><span class="text-uppercase" t-field="o.loan_type_id.name"/> SUMMARY<br/></span>

<span style="font-weight:bold;font-family:Liberation Sans;font-size:10px;">FOR THE MONTH OF <span class="text-uppercase" t-esc="time.strftime('%B, %Y', time.strptime(o.from_date,'%Y-%m-%d'))"/><br/></span>

</div>

</th>

</tr>

<tr style="font-size:12;font-weight:bold;background-color:#d6d8db;text-align:center;border: 1px solid #000000;">

<th style="width:5%;padding:8px;text-align:center;vertical-align:center;border: 1px solid #000000;">ID NO.</th>

<th style="width:30%;padding:8px;text-align:center;vertical-align:center;border: 1px solid #000000;">EMPLOYEE'S NAME</th>

<th style="width:5%;padding:8px;text-align:center;vertical-align:center;border: 1px solid #000000;">15TH</th>

<th style="width:5%;padding:8px;text-align:center;vertical-align:center;border: 1px solid #000000;"><span t-esc="o.get_last_day_month(o.to_date)"/> </th>

<th style="width:5%;padding:8px;text-align:center;vertical-align:center;border: 1px solid #000000;">TOTAL</th>

</tr>

</thead>

<!--<t t-foreach="records.sorted(key=lambda r: r.employee_id.name)" t-as="rec">-->

<t t-set="employee_ids" t-value="[]"/>

<t t-foreach="records.sorted(key=lambda r: r.loan_id.employee_id)" t-as="recs">

<t t-if="recs.loan_id.employee_id.company_id.id == company.id">

<t t-set="employee_ids" t-value="employee_ids+[recs.loan_id.employee_id]"/>

</t>

</t>

<t t-foreach="o.get_sorted(list(set(employee_ids)))" t-as="employee">

<tbody>

<tr style="font-size:12px;">

<t t-set="loan_1" t-value="0"/>

<t t-set="loan_2" t-value="0"/>

<td style="width:5%;padding:8px;text-align:left;vertical-align:center;">

<span class="text-uppercase"><span t-esc="employee.identification_id"/></span>

</td>

<td style="width:30%;padding:8px;text-align:left;vertical-align:center;">

<span t-esc="employee.name"/>

</td>

<td style="width:5%;padding:8px;text-align:center;vertical-align:center;">

<t t-set="loan_1" t-value="0"/>

<t t-set="loan_1" t-value="sum([rec.paid_amount for rec in records if rec.loan_id.employee_id.id == employee.id and rec.loan_type_id.id == o.loan_type_id.id and rec.payroll_id.payslip_run_id.hr_period_id.vale_period == 1])"/>

<t t-esc="'{0:,.2f}'.format((loan_1))"/>

</td>

<td style="width:5%;padding:8px;text-align:center;vertical-align:center;">

<t t-set="loan_2" t-value="0"/>

<t t-set="loan_2" t-value="sum([rec.paid_amount for rec in records if rec.loan_id.employee_id.id == employee.id and rec.loan_type_id.id == o.loan_type_id.id and rec.payroll_id.payslip_run_id.hr_period_id.vale_period == 2])"/>

<t t-esc="'{0:,.2f}'.format((loan_2))"/>

</td>

<td style="width:5%;padding:8px;text-align:right;vertical-align:center;">

<span t-esc="'{0:,.2f}'.format(loan_2 + loan_1)"/>

</td>

</tr>

</tbody>

</t>

<tr>

<t t-set="total_loan_1" t-value="0"/>

<t t-set="total_loan_2" t-value="0"/>

<td style="vertical-align:center;text-align:center;padding:5px;border: 1px solid #000000;" colspan="2">

<strong><span>GRAND TOTAL</span></strong>

</td>

<td style="vertical-align:center;text-align:right;padding:5px;font-weight:bold;border: 1px solid #000000;">

<t t-set="total_loan_1" t-value="0"/>

<t t-set="total_loan_1" t-value="sum([rec.paid_amount for rec in records if rec.loan_type_id.id == o.loan_type_id.id and rec.payroll_id.payslip_run_id.hr_period_id.vale_period == 1])"/>

<t t-esc="'{0:,.2f}'.format((total_loan_1))"/>

</td>

<td style="vertical-align:center;text-align:right;padding:5px;font-weight:bold;border: 1px solid #000000;">

<t t-set="total_loan_2" t-value="0"/>

<t t-set="total_loan_2" t-value="sum([rec.paid_amount for rec in records if rec.loan_type_id.id == o.loan_type_id.id and rec.payroll_id.payslip_run_id.hr_period_id.vale_period == 2])"/>

<t t-esc="'{0:,.2f}'.format((total_loan_2))"/>

</td>

<td style="vertical-align:center;text-align:right;padding:5px;font-weight:bold;border: 1px solid #000000;">

<t t-esc="'{0:,.2f}'.format((total_loan_1 + total_loan_2))"/>

</td>

</tr>

</table><br/>

</div>

</t>

</div>

</t>

</div>

<div class="footer">

<i>

<div class="text-left">

<span style="font-size:12px;"><i>Date printed: <span t-esc="context_timestamp(datetime.datetime.now()).strftime('%B %d, %Y %I:%M:%S %p')"/></i></span>

</div>

<div class="text-center">

<ul class="list-inline">

<li>Page:</li>

<li><span class="page"/></li>

<li>/</li>

<li><span class="topage"/></li>

</ul>

</div>

</i>

</div>

</t>

</t>

</template>

</data>

</odoo>