Reviewers: ,

Description:
Selection widget of Dict fields should test if the value is in the list

Please review this at http://codereview.tryton.org/810002/

Affected files:
  M tryton/gui/window/view_form/view/form_gtk/dictionary.py


Index: tryton/gui/window/view_form/view/form_gtk/dictionary.py
===================================================================
--- a/tryton/gui/window/view_form/view/form_gtk/dictionary.py
+++ b/tryton/gui/window/view_form/view/form_gtk/dictionary.py
@@ -111,7 +111,16 @@

     def get_value(self):
         text = self.widget.child.get_text()
-        return self._selection[text]
+        value = None
+        if text:
+            for txt, val in self._selection.items():
+                if not val:
+                    continue
+                if txt[:len(text)].lower() == text.lower():
+                    value = val
+                    if len(txt) == len(text):
+                        break
+        return value

     def set_value(self, value):
         values = dict(self.definition['selection'])


Reply via email to