[FIX] account_budget: clearer analytic budget report

Before this commit there were two issues:
- The date "from and to" set in the wizard weren't working, as in not used at all
- The lines in the report did not have a date range, making the understanding of the report difficult

after this commit, only the budget lines which dates overlap at least one day of the report's dates will be selected.
Also, the first line of the report, containing the budget name also contains the dates on which it applies

OPW 743441

Closes #18737
This commit is contained in:
Lucas Perais (lpe)
2017-08-16 09:09:22 +02:00
parent eaa95bd0a6
commit ff30928786
3 changed files with 17 additions and 5 deletions
@@ -78,11 +78,16 @@ class analytic_account_budget_report(report_sxw.rml_parse):
'theo':0.00,
'pln':0.00,
'prac':0.00,
'perc':0.00
'perc':0.00,
'date_from': budget_name[0].date_from,
'date_to': budget_name[0].date_to,
}
result.append(res)
line_ids = c_b_lines_obj.search(self.cr, self.uid, [('id', 'in', b_line_ids), ('crossovered_budget_id','=',budget_ids[i][0])])
domain_lines = [('id', 'in', b_line_ids),
('crossovered_budget_id', '=', budget_ids[i][0]),
('date_from', '<=', d_to),
('date_to', '>=', d_from)]
line_ids = c_b_lines_obj.search(self.cr, self.uid, domain_lines)
line_id = c_b_lines_obj.browse(self.cr, self.uid, line_ids)
tot_theo = tot_pln = tot_prac = tot_perc = 0
@@ -84,8 +84,11 @@ class budget_report(report_sxw.rml_parse):
'perc': 0.00
}
result.append(res)
line_ids = c_b_lines_obj.search(self.cr, self.uid, [('id', 'in', budget_ids), ('analytic_account_id','=',an_ids[i][0])])
domain_lines = [('id', 'in', budget_ids),
('analytic_account_id','=',an_ids[i][0]),
('date_from', '<=', d_to),
('date_to', '>=', d_from)]
line_ids = c_b_lines_obj.search(self.cr, self.uid, domain_lines)
line_id = c_b_lines_obj.browse(self.cr, self.uid, line_ids)
tot_theo = tot_pln = tot_prac = tot_perc = 0.00
@@ -32,6 +32,8 @@
<th class="text-right">Planned Amt</th>
<th class="text-right">Practical Amt</th>
<th class="text-right">Perc(%)</th>
<th class="text-right">Start date</th>
<th class="text-right">End Date</th>
</tr>
</thead>
<tbody>
@@ -42,6 +44,8 @@
<td class="text-right"><strong t-esc="formatLang(line['pln'], dp='Account', currency_obj=res_company.currency_id)"/></td>
<td class="text-right"><strong t-esc="formatLang(line['prac'], dp='Account', currency_obj=res_company.currency_id)"/></td>
<td class="text-right"><strong t-esc="formatLang(line['perc'], digits=2)"/> %</td>
<td class="text-right"><strong t-esc="formatLang(line.get('date_from') or '', date=True)"/></td>
<td class="text-right"><strong t-esc="formatLang(line.get('date_to') or '', date=True)"/></td>
</tr>
<tr t-if="line['status'] != 1">
<td><span style="color: white;" t-esc="'.....'*(line['status'] - 1)"/><span t-esc="line['name']"/></td>