From 299d4921c8cf43b2d1104d50dede49fe4f9d127d Mon Sep 17 00:00:00 2001 From: Yolann Sabaux Date: Thu, 5 Jan 2023 09:52:11 +0000 Subject: [PATCH] [FIX] account: render rounding line MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- addons/account/models/account_move.py | 4 ++++ .../static/src/components/tax_totals/tax_totals.xml | 12 ++++++++++++ addons/account/views/report_invoice.xml | 10 +++++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index e01033cbabb..3a803dba0f5 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -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 diff --git a/addons/account/static/src/components/tax_totals/tax_totals.xml b/addons/account/static/src/components/tax_totals/tax_totals.xml index 841fff0258e..be1ab967dcc 100644 --- a/addons/account/static/src/components/tax_totals/tax_totals.xml +++ b/addons/account/static/src/components/tax_totals/tax_totals.xml @@ -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;' }}" + /> + + + + + + + + + diff --git a/addons/account/views/report_invoice.xml b/addons/account/views/report_invoice.xml index 3d0357e01a8..91e0a1371af 100644 --- a/addons/account/views/report_invoice.xml +++ b/addons/account/views/report_invoice.xml @@ -282,13 +282,21 @@ + - Total + Total + Total + + Total Rounded + + + +