Reviewers: ,
Please review this at http://codereview.tryton.org/687002/
Affected files:
tryton/gui/window/view_form/screen/screen.py
tryton/gui/window/view_form/view/form_gtk/one2many.py
tryton/gui/window/view_form/view/list.py
Index: tryton/gui/window/view_form/screen/screen.py
===================================================================
--- a/tryton/gui/window/view_form/screen/screen.py
+++ b/tryton/gui/window/view_form/screen/screen.py
@@ -225,10 +225,6 @@
self.parent_name = group.parent_name
if self.parent:
self.filter_widget = None
- if len(group):
- self.current_record = group[0]
- else:
- self.current_record = None
self.__group.signal_connect(self, 'group-cleared',
self._group_cleared)
self.__group.signal_connect(self, 'group-list-changed',
self._group_list_changed)
@@ -237,6 +233,10 @@
self.__group.signal_connect(self, 'group-changed',
self._group_changed)
self.__group.add_fields(fields)
self.__group.exclude_field = self.exclude_field
+ if len(group):
+ self.current_record = group[0]
+ else:
+ self.current_record = None
group = property(__get_group, __set_group)
Index: tryton/gui/window/view_form/view/form_gtk/one2many.py
===================================================================
--- a/tryton/gui/window/view_form/view/form_gtk/one2many.py
+++ b/tryton/gui/window/view_form/view/form_gtk/one2many.py
@@ -2,6 +2,7 @@
#this repository contains the full copyright notices and license terms.
import gtk
import gettext
+import gobject
from interface import WidgetInterface
from tryton.gui.window.view_form.screen import Screen
@@ -181,6 +182,9 @@
exclude_field=attrs.get('relation_field', None))
self.screen.pre_validate = bool(int(attrs.get('pre_validate', 0)))
self.screen.signal_connect(self, 'record-message', self._sig_label)
+ if self.attrs.get('group'):
+ self.screen.signal_connect(self, 'record-message',
+ lambda screen, _: gobject.idle_add(self.group_sync,
screen))
self.widget.pack_start(self.screen.widget, expand=True, fill=True)
@@ -426,6 +430,25 @@
self.label.set_text(line)
self._set_button_sensitive()
+ def group_sync(self, screen):
+ if not self.view or not self.view.widgets:
+ return
+ current_record = self.screen.current_record
+ for widget in self.view.widgets[self.field_name]:
+ if (widget == self
+ or widget.attrs.get('group') != self.attrs['group']
+ or not hasattr(widget, 'screen')):
+ continue
+ if widget.screen.current_record == current_record:
+ continue
+ if not widget._validate():
+ def go_previous():
+ screen.current_record = widget.screen.current_record
+ gobject.idle_add(go_previous)
+ break
+ widget.screen.current_record = current_record
+ widget.screen.display()
+
def display(self, record, field):
super(One2Many, self).display(record, field)
Index: tryton/gui/window/view_form/view/list.py
===================================================================
--- a/tryton/gui/window/view_form/view/list.py
+++ b/tryton/gui/window/view_form/view/list.py
@@ -808,10 +808,12 @@
self.widget_tree.set_model(self.store)
self.reload = False
if not self.screen.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)
+ else:
+ path = self.screen.current_record.get_path(self.screen.group)
+ path = path_convert_id2pos(self.store, [i[1] for i in path])
+ self.widget_tree.set_cursor(path)
self.widget_tree.queue_draw()
if hasattr(self.widget_tree, 'editable') \
and self.widget_tree.editable:
--
--
[email protected] mailing list
---
You received this message because you are subscribed to the Google Groups "tryton-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.