From 35c4d729f3931ad7bcfba447a6bd150c4e90ac8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 31 Oct 2023 21:42:11 +0100 Subject: [PATCH] Do not fail when parsing invalid Decimal value in number entry Closes #12692 (grafted from f9c0481e7aad3c8229f1660d7367b0edd803389b) --HG-- branch : 6.0 --- tryton/tryton/common/number_entry.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tryton/tryton/common/number_entry.py b/tryton/tryton/common/number_entry.py index e524598b9e..c6eb228ef2 100644 --- a/tryton/tryton/common/number_entry.py +++ b/tryton/tryton/common/number_entry.py @@ -2,7 +2,7 @@ # this repository contains the full copyright notices and license terms. import gettext import locale -from decimal import Decimal +from decimal import Decimal, InvalidOperation from gi.repository import Gdk, GObject, Gtk @@ -54,7 +54,7 @@ class NumberEntry(Gtk.Entry, Gtk.Editable): if text not in ['-', self.__decimal_point]: try: value = Decimal(locale.atof(text)) - except ValueError: + except (ValueError, InvalidOperation): return position if (value and self.__digits is not None and (round(value, self.__digits) != value