Don't set cursor when displaying widget and correctly manage selection in list view
When clicking on new, a new record instance is set as current_record and display is called. But as the changeset ff6dc4d5bff6 adds a call to display with set_cursor, it triggers the focus out of the widget having the cursor which could set the value of the previous record to the new record if the widget was not yet displayed. So display on widget should never set the cursor but indeed it is the display of the list view that must set the correct selection when the store is changed. issue3757 review4481002
This commit is contained in:
1 parent
492bf98139
commit
5565843603
2 files changed
+7
-7
No files matched your search
@@ -447,10 +447,8 @@ class One2Many(WidgetInterface):
|
||||
return False
|
||||
new_group = field.get_client(record)
|
||||
|
||||
set_cursor = False
|
||||
if id(self.screen.group) != id(new_group):
|
||||
self.screen.group = new_group
|
||||
set_cursor = True
|
||||
if (self.screen.current_view.view_type == 'tree') \
|
||||
and self.screen.current_view.editable:
|
||||
self.screen.current_record = None
|
||||
@@ -466,7 +464,7 @@ class One2Many(WidgetInterface):
|
||||
if not self.screen.group.readonly and readonly:
|
||||
self.screen.group.readonly = readonly
|
||||
self.screen.size_limit = size_limit
|
||||
self.screen.display(set_cursor=set_cursor)
|
||||
self.screen.display()
|
||||
return True
|
||||
|
||||
def set_value(self, record, field):
|
||||
|
||||
@@ -781,12 +781,14 @@ class ViewList(ParserView):
|
||||
self.widget_tree.set_model(self.store)
|
||||
# __select_changed resets current_record to None
|
||||
self.screen.current_record = current_record
|
||||
if current_record:
|
||||
selection = self.widget_tree.get_selection()
|
||||
path = self.store.on_get_path(current_record)
|
||||
selection.select_path(path)
|
||||
self.reload = False
|
||||
if not current_record:
|
||||
# Should find a simpler solution to do something like
|
||||
#self.widget.set_cursor(None,None,False)
|
||||
if self.store:
|
||||
self.widget_tree.set_model(self.store)
|
||||
selection = self.widget_tree.get_selection()
|
||||
selection.unselect_all()
|
||||
self.widget_tree.queue_draw()
|
||||
if self.editable:
|
||||
self.set_state()
|
||||
|
||||
Reference in new issue
Block a user