Fix: formulaires: saisie nombres/ exception

This commit is contained in:
Emmanuel Viennet 2023-02-21 02:08:50 +01:00
parent cac6201696
commit 7a7c2f1778
2 changed files with 15 additions and 4 deletions

View File

@ -370,12 +370,23 @@ class TF(object):
self.values[field] = True self.values[field] = True
else: else:
self.values[field] = False self.values[field] = False
# open('/tmp/toto','a').write('checkvalues: val=%s (%s) values[%s] = %s\n' % (val, type(val), field, self.values[field]))
if descr.get("convert_numbers", False): if descr.get("convert_numbers", False):
if typ[:3] == "int": if typ[:3] == "int":
self.values[field] = int(self.values[field]) try:
self.values[field] = int(self.values[field])
except ValueError:
msg.append(
f"valeur invalide ({self.values[field]}) pour le champs {field}"
)
ok = False
elif typ == "float" or typ == "real": elif typ == "float" or typ == "real":
self.values[field] = float(self.values[field].replace(",", ".")) try:
self.values[field] = float(self.values[field].replace(",", "."))
except ValueError:
msg.append(
f"valeur invalide ({self.values[field]}) pour le champs {field}"
)
ok = False
if ok: if ok:
self.result = self.values self.result = self.values
else: else:

View File

@ -1,7 +1,7 @@
# -*- mode: python -*- # -*- mode: python -*-
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
SCOVERSION = "9.4.46" SCOVERSION = "9.4.47"
SCONAME = "ScoDoc" SCONAME = "ScoDoc"