From b79d8b99ff39d1889df89debed012fc7cc54598e Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Tue, 10 Apr 2018 12:39:58 +0200 Subject: [FIX] base: amount_to_text possible difference In 79038055 amount_to_text was refactored and improved, but there is a drawback. ie. if we have .29 cents with two decimals, `Twenty-Eight` was displayed because `int(0.29 * 100) == 28` due to floating-point representation. This commit keeps the improvements and fix this issue by using string formatting of float as was done before. opw-1829924 closes #24161 --- odoo/addons/base/tests/test_float.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'odoo/addons/base/tests/test_float.py') diff --git a/odoo/addons/base/tests/test_float.py b/odoo/addons/base/tests/test_float.py index 6dc1cda0550..c55ba2588f3 100644 --- a/odoo/addons/base/tests/test_float.py +++ b/odoo/addons/base/tests/test_float.py @@ -203,3 +203,12 @@ class TestFloatPrecision(TransactionCase): with self.assertRaises(AssertionError): float_round(0.01, precision_digits=3, precision_rounding=0.01) + + def test_amount_to_text_10(self): + """ verify that amount_to_text works as expected """ + currency = self.env.ref('base.EUR') + + amount_target = currency.amount_to_text(0.29) + amount_test = currency.amount_to_text(0.28) + self.assertNotEqual(amount_test, amount_target, + "Amount in text should not depend on float representation") -- cgit v1.2.3