Ila Rana(Open ERP) has proposed merging
lp:~openerp-dev/openobject-client/6.0-opw-16402-ira into
lp:openobject-client/6.0.
Requested reviews:
OpenERP Core Team (openerp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-client/6.0-opw-16402-ira/+merge/69232
Hello,
In GTK-client, property fields is not working if the widget = "selection" type
and field name value is not unique. So, I have improved selection.py of both
form_gtk and widget_search.
Regards,
Ila Rana.
--
https://code.launchpad.net/~openerp-dev/openobject-client/6.0-opw-16402-ira/+merge/69232
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-client/6.0-opw-16402-ira.
=== modified file 'bin/widget/view/form_gtk/selection.py'
--- bin/widget/view/form_gtk/selection.py 2010-07-16 05:41:32 +0000
+++ bin/widget/view/form_gtk/selection.py 2011-07-26 09:41:33 +0000
@@ -45,18 +45,18 @@
# the dropdown button is not focusable by a tab
self.widget.set_focus_chain([self.child])
self.ok = True
- self._selection={}
+ self._selection = []
self.set_popdown(attrs.get('selection', []))
def set_popdown(self, selection):
self.model = gtk.ListStore(gobject.TYPE_STRING)
- self._selection={}
+ self._selection = []
lst = []
for (value, name) in selection:
name = str(name)
lst.append(name)
- self._selection[name] = value
+ self._selection.append((name,value))
i = self.model.append()
self.model.set(i, 0, name)
self.entry.set_model(self.model)
@@ -69,7 +69,8 @@
def value_get(self):
res = self.child.get_text()
- return self._selection.get(res, False)
+ result = [y for x,y in self._selection if x==res]
+ return result and result[0] or False
def sig_key_press(self, widget, event):
# allow showing available entries by hitting "ctrl+space"
@@ -94,7 +95,7 @@
text = self.child.get_text()
value = False
if text:
- for txt, val in self._selection.items():
+ for txt, val in self._selection:
if not val:
continue
if txt[:len(text)].lower() == text.lower():
@@ -124,7 +125,7 @@
self.child.set_text('')
else:
found = False
- for long_text, sel_value in self._selection.items():
+ for long_text, sel_value in self._selection:
if sel_value == value:
self.child.set_text(long_text)
found = True
=== modified file 'bin/widget_search/selection.py'
--- bin/widget_search/selection.py 2011-01-17 19:11:21 +0000
+++ bin/widget_search/selection.py 2011-07-26 09:41:33 +0000
@@ -32,7 +32,7 @@
self.widget = gtk.combo_box_entry_new_text()
self.widget.child.set_editable(True)
self.attrs = attrs
- self._selection = {}
+ self._selection = []
self.name = name
self.val_id = False
if 'selection' in attrs:
@@ -42,20 +42,20 @@
self._value_set(int(self.default_search))
else:
self._value_set(str(self.default_search))
- if self.widget.child.get_text() in self._selection.keys():
+ if self.widget.child.get_text() in [x for x,y in self._selection]:
self.widget.set_active(self.indexes[self.widget.child.get_text()]-1)
def set_popdown(self, selection):
self.model = self.widget.get_model()
self.model.clear()
- self._selection={}
+ self._selection = []
lst = []
for (i,j) in selection:
name = str(j)
lst.append(name)
- self._selection[name]=i
+ self._selection.append((name,i))
ind=1
- if '' not in self._selection:
+ if '' not in [x for x,y in self._selection]:
self.widget.append_text('')
ind += 1
self.indexes = {}
@@ -78,7 +78,8 @@
completion.set_text_column(0)
# Setting the selected value active on the entry widget while selection is made by keypress
- if self._selection.get(widget.get_text(),''):
+ result = [y for x,y in self._selection if x==widget.get_text()]
+ if result:
# to let this value count into domain calculation
self.widget.set_active(self.indexes[widget.get_text()])
@@ -86,8 +87,9 @@
res = self.widget.child.get_text()
context = {}
operator = 'ilike'
- if self._selection.get(res, False):
- res = self._selection.get(res, False)
+ result = [y for x,y in self._selection if x==res]
+ if result:
+ res = result[0]
operator = self.attrs.get('operator','=')
context = tools.expr_eval(self.attrs.get('context',"{}"), {'self':res})
if res:
@@ -100,9 +102,9 @@
def _value_set(self, value):
if value==False:
value=''
- for s in self._selection:
- if self._selection[s]==value:
- self.widget.child.set_text(s)
+ for text,val in self._selection:
+ if val == value:
+ self.widget.child.set_text(text)
def clear(self):
self.widget.child.set_text('')
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp