From 6df542f08ded7e73637d45be52c97918af08fa98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 10 Oct 2014 10:05:09 +0200 Subject: [PATCH] Don't restore text on many2one cleaning if not empty The call to set_client in clean function could trigger a on_change that will set a value to the current field. In such case, the previous text should not be restored. issue4238 review5701002 --- tryton/gui/window/view_form/view/form_gtk/many2one.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tryton/gui/window/view_form/view/form_gtk/many2one.py b/tryton/gui/window/view_form/view/form_gtk/many2one.py index f152db7ea5..99a795f382 100644 --- a/tryton/gui/window/view_form/view/form_gtk/many2one.py +++ b/tryton/gui/window/view_form/view/form_gtk/many2one.py @@ -257,9 +257,12 @@ class Many2One(Widget): position = self.wid_text.get_position() self.field.set_client(self.record, self.value_from_id(None, '')) - # Restore text and position after display - self.wid_text.set_text(text) - self.wid_text.set_position(position) + # The value of the field could be different of None + # in such case, the original text should not be restored + if not self.wid_text.get_text(): + # Restore text and position after display + self.wid_text.set_text(text) + self.wid_text.set_position(position) gobject.idle_add(clean) return False