From 636f24cef9215e649ff06e30613e3e5733309fe8 Mon Sep 17 00:00:00 2001 From: "Guillaume (guva)" Date: Wed, 9 Feb 2022 12:10:08 +0000 Subject: [PATCH] [FIX] account: decimal separator on vendor bill Steps to reproduce: - Set a language which use ',' (comma) as decimal separator (eg French) - Make a Vendor Bill for any product at any price. If the partner's language use '.' (period) as decimal separator (eg English), the field amount_by_group is formated whit period, while others are formated with comma. They should all be formated with comma. - Now print the Vendor Bill The same issue is occuring. With Customer Invoices, the issue is the same on the form view, but not on the printing, where all the fields are formated with period, as set in the partner's language. After this commit, we format all the fields regarding the environment's language on the view form, either in Vendor Bills and Customer Invoices, and we formating the printed bill/invoice regarding the partner's language opw-2735698 closes odoo/odoo#84666 X-original-commit: bb029a476a04b7d41ea1f585274d24f581b4003d Signed-off-by: Florian Gilbert Signed-off-by: Guillaume Vanleynseele --- addons/account/models/account_move.py | 11 +++++------ addons/account/views/report_invoice.xml | 4 ++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index c3fa9fe25ea..4038fba9ca7 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -1843,7 +1843,6 @@ class AccountMove(models.Model): } } """ - lang_env = self.with_context(lang=partner.lang).env account_tax = self.env['account.tax'] grouped_taxes = defaultdict(lambda: defaultdict(lambda: {'base_amount': 0.0, 'tax_amount': 0.0, 'base_line_keys': set()})) @@ -1889,8 +1888,8 @@ class AccountMove(models.Model): 'tax_group_name': group.name, 'tax_group_amount': amounts['tax_amount'], 'tax_group_base_amount': amounts['base_amount'], - 'formatted_tax_group_amount': formatLang(lang_env, amounts['tax_amount'], currency_obj=currency), - 'formatted_tax_group_base_amount': formatLang(lang_env, amounts['base_amount'], currency_obj=currency), + 'formatted_tax_group_amount': formatLang(self.env, amounts['tax_amount'], currency_obj=currency), + 'formatted_tax_group_base_amount': formatLang(self.env, amounts['base_amount'], currency_obj=currency), 'tax_group_id': group.id, 'group_key': '%s-%s' %(subtotal_title, group.id), } for group, amounts in sorted(groups.items(), key=lambda l: l[0].sequence)] @@ -1905,7 +1904,7 @@ class AccountMove(models.Model): subtotals_list.append({ 'name': subtotal_title, 'amount': subtotal_value, - 'formatted_amount': formatLang(lang_env, subtotal_value, currency_obj=currency), + 'formatted_amount': formatLang(self.env, subtotal_value, currency_obj=currency), }) subtotal_tax_amount = sum(group_val['tax_group_amount'] for group_val in groups_by_subtotal[subtotal_title]) @@ -1915,8 +1914,8 @@ class AccountMove(models.Model): return { 'amount_total': amount_total, 'amount_untaxed': amount_untaxed, - 'formatted_amount_total': formatLang(lang_env, amount_total, currency_obj=currency), - 'formatted_amount_untaxed': formatLang(lang_env, amount_untaxed, currency_obj=currency), + 'formatted_amount_total': formatLang(self.env, amount_total, currency_obj=currency), + 'formatted_amount_untaxed': formatLang(self.env, amount_untaxed, currency_obj=currency), 'groups_by_subtotal': groups_by_subtotal, 'subtotals': subtotals_list, 'allow_tax_edition': False, diff --git a/addons/account/views/report_invoice.xml b/addons/account/views/report_invoice.xml index b3e91d1d7f6..a15820bde5f 100644 --- a/addons/account/views/report_invoice.xml +++ b/addons/account/views/report_invoice.xml @@ -259,7 +259,7 @@