From dba19e22eaf13b2976ccd14be7380b11e3415164 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 24 Feb 2009 22:49:34 +0100 Subject: [PATCH] Improve check for float encoding with digits for issue806 --- tryton/gui/window/view_form/view/form_gtk/float.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tryton/gui/window/view_form/view/form_gtk/float.py b/tryton/gui/window/view_form/view/form_gtk/float.py index adf21ab0b0..a13d2d0e7d 100644 --- a/tryton/gui/window/view_form/view/form_gtk/float.py +++ b/tryton/gui/window/view_form/view/form_gtk/float.py @@ -37,7 +37,17 @@ class Float(Integer): try: if new_value == '-': return - if len(str(int(locale.atof(new_value)))) > self.digits[0]: + + if isinstance(self.digits, str): + digits = self._view.model.expr_eval(self.digits) + else: + digits = self.digits + + if len(str(int(locale.atof(new_value)))) > digits[0]: + entry.stop_emission('insert-text') + + exp_value = locale.atof(new_value) * (10 ** digits[1]) + if exp_value - int(exp_value) != 0.0: entry.stop_emission('insert-text') except: entry.stop_emission('insert-text')