diff --git a/tryton/common/cellrendererfloat.py b/tryton/common/cellrendererfloat.py index def4cb9c57..5042f947f2 100644 --- a/tryton/common/cellrendererfloat.py +++ b/tryton/common/cellrendererfloat.py @@ -19,12 +19,19 @@ class CellRendererFloat(CellRendererInteger): if new_value == '-': return - if len(str(int(locale.atof(new_value)))) > self.digits[0]: + locale.atof(new_value) + + decimal_point = locale.localeconv()['decimal_point'] + + new_int = new_value + new_decimal = '' + if decimal_point in new_value: + new_int, new_decimal = new_value.rsplit(decimal_point, 1) + + if len(new_int) > self.digits[0] \ + or len(new_decimal) > self.digits[1]: entry.stop_emission('insert-text') - exp_value = locale.atof(new_value) * (10 ** self.digits[1]) - if exp_value - int(exp_value) != 0.0: - entry.stop_emission('insert-text') except: entry.stop_emission('insert-text') 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 ed0970be00..992e3b4b47 100644 --- a/tryton/gui/window/view_form/view/form_gtk/float.py +++ b/tryton/gui/window/view_form/view/form_gtk/float.py @@ -44,11 +44,18 @@ class Float(Integer): else: digits = self.digits - if len(str(int(locale.atof(new_value)))) > digits[0]: + locale.atof(new_value) + + decimal_point = locale.localeconv()['decimal_point'] + + new_int = new_value + new_decimal = '' + if decimal_point in new_value: + new_int, new_decimal = new_value.rsplit(decimal_point, 1) + + if len(new_int) > digits[0] \ + or len(new_decimal) > digits[1]: 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')