[FIX] account: render rounding line

Steps to reproduce:
- create a cash rounding
- create an invoice
- in Other Infos, select the created Cash Rounding Method

Issue:
Accounting wise, everything works fine but the back-end view and the Invoice Reports do not take into account the rounding
(except wen you create a partial payment, the amount due is correct of course)

Solution:
Make sure the value `formatted_amount_total_rounded` is returned by the method `_prepare_tax_totals` so it can be used in the templates

opw-3090556

closes odoo/odoo#109312

X-original-commit: 5724858a374c894bf787b4381bdcd466b4cc2816
Signed-off-by: William André (wan) <wan@odoo.com>
This commit is contained in:
Yolann Sabaux
2023-01-06 14:31:52 +01:00
parent 3ac3d78e21
commit 299d4921c8
3 changed files with 25 additions and 1 deletions
+4
View File
@@ -1168,6 +1168,10 @@ class AccountMove(models.Model):
handle_price_include=False,
))
move.tax_totals = self.env['account.tax']._prepare_tax_totals(**kwargs)
rounding_line = move.line_ids.filtered(lambda l: l.display_type == 'rounding')
if rounding_line:
amount_total_rounded = move.tax_totals['amount_total'] - rounding_line.balance
move.tax_totals['formatted_amount_total_rounded'] = formatLang(self.env, amount_total_rounded, currency_obj=move.currency_id) or ''
else:
# Non-invoice moves don't support that field (because of multicurrency: all lines of the invoice share the same currency)
move.tax_totals = None
@@ -75,6 +75,18 @@
name="amount_total"
t-att-class="Object.keys(totals.groups_by_subtotal).length > 0 ? 'oe_subtotal_footer_separator' : ''"
t-out="totals.formatted_amount_total"
t-attf-style="{{ !totals.formatted_amount_total_rounded ? 'font-size: 1.3em; font-weight: bold; white-space: nowrap;' : 'font-size: 1em;' }}"
/>
</td>
</tr>
<tr t-if="totals.formatted_amount_total_rounded">
<td class="o_td_label">
<label class="o_form_label o_tax_total_label">Total Rounded</label>
</td>
<td>
<span
t-out="totals.formatted_amount_total_rounded"
style="white-space: nowrap; font-weight: bold; font-size: 1.3em;"
/>
</td>
+9 -1
View File
@@ -282,13 +282,21 @@
<t t-call="account.tax_groups_totals"/>
</t>
<t t-set="has_rounding" t-value="'formatted_amount_total_rounded' in tax_totals"/>
<!--Total amount with all taxes-->
<tr class="border-black o_total">
<td><strong>Total</strong></td>
<t t-if="has_rounding"><td>Total</td></t>
<t t-else=""><td><strong>Total</strong></td></t>
<td class="text-end">
<span t-out="tax_totals['formatted_amount_total']"/>
</td>
</tr>
<tr t-if="has_rounding">
<td><strong>Total Rounded</strong></td>
<td class="text-end">
<span t-esc="tax_totals['formatted_amount_total_rounded']"/>
</td>
</tr>
</template>
<template id="tax_groups_totals">