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
This commit is contained in:
Sergi Almacellas Abellana committed 2018-02-07 12:26:59 +01:00
1 parent a9595f3c25
commit b53fcf111a
1 file changed
+1 -1
+1 -1
View File
@@ -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: