From b53fcf111a9849e599ad75eb4f4878b25dead5cd Mon Sep 17 00:00:00 2001 From: Sergi Almacellas Abellana Date: Wed, 7 Feb 2018 12:26:59 +0100 Subject: [PATCH] Do not strip trailing zeros on Decimal digits validation In order to support the 0 digits case rstrip was introduced in changeset d3fec5da0dbdbut it breaks the case where the number of digits is high as python uses manting representation when converting the float value to string. This causes the last trailing zero is also removed which breaks the validation. issue7091 review37981002 --- trytond/model/modelstorage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trytond/model/modelstorage.py b/trytond/model/modelstorage.py index 93e40b1ba8..33b93c4aba 100644 --- a/trytond/model/modelstorage.py +++ b/trytond/model/modelstorage.py @@ -1093,7 +1093,7 @@ class ModelStorage(Model): or any(d is None for d in digits)): return if isinstance(value, Decimal): - exp = Decimal(str(10.0 ** -digits[1]).rstrip('0')) + exp = Decimal('.'.join(['0', '0' * digits[1]])) if value.quantize(exp) != value: raise_user_error(value) else: