diff --git a/tryton/gui/window/preference.py b/tryton/gui/window/preference.py index b3884c7ac1..10050a7336 100644 --- a/tryton/gui/window/preference.py +++ b/tryton/gui/window/preference.py @@ -55,6 +55,7 @@ class Preference(NoModal): self.screen.group.readonly = False self.screen.group.skip_model_access = True self.screen.add_view(view) + self.screen.switch_view() self.screen.new(default=False) try: diff --git a/tryton/gui/window/view_form/screen/screen.py b/tryton/gui/window/view_form/screen/screen.py index 8150739e3a..748316677c 100644 --- a/tryton/gui/window/view_form/screen/screen.py +++ b/tryton/gui/window/view_form/screen/screen.py @@ -88,8 +88,8 @@ class Screen(SignalEvent): self.domain_parser = None self.pre_validate = False self.view_to_load = mode[:] - self.load_view_to_load() - self.display() + if view_ids or mode: + self.switch_view() def __repr__(self): return '' % (self.model_name, id(self)) @@ -329,18 +329,19 @@ class Screen(SignalEvent): return len(self.views) + len(self.view_to_load) def switch_view(self, view_type=None): - if not self.parent and self.modified(): - return - self.current_view.set_value() - if (self.current_record and - self.current_record not in self.current_record.group): - self.current_record = None - fields = self.current_view.get_fields() - if self.current_record and not self.current_record.validate(fields): - self.screen_container.set(self.current_view.widget) - self.set_cursor() - self.current_view.display() - return + if self.current_view: + if not self.parent and self.modified(): + return + self.current_view.set_value() + if (self.current_record and + self.current_record not in self.current_record.group): + self.current_record = None + fields = self.current_view.get_fields() + if self.current_record and not self.current_record.validate(fields): + self.screen_container.set(self.current_view.widget) + self.set_cursor() + self.current_view.display() + return if not view_type or self.current_view.view_type != view_type: for i in xrange(self.number_of_views): if len(self.view_to_load): @@ -413,9 +414,6 @@ class Screen(SignalEvent): children_field=children_field) self.views.append(view) - - self.__current_view = len(self.views) - 1 - self.screen_container.set(self.current_view.widget) return view def editable_get(self): diff --git a/tryton/gui/window/win_form.py b/tryton/gui/window/win_form.py index 48ddf04176..f6e75bcafa 100644 --- a/tryton/gui/window/win_form.py +++ b/tryton/gui/window/win_form.py @@ -30,8 +30,7 @@ class WinForm(NoModal): if view_type not in (x.view_type for x in self.screen.views) and \ view_type not in self.screen.view_to_load: self.screen.add_view_id(None, view_type) - else: - self.screen.switch_view(view_type=view_type) + self.screen.switch_view(view_type=view_type) if new: self.screen.new() self.win = gtk.Dialog(_('Link'), self.parent, diff --git a/tryton/gui/window/wizard.py b/tryton/gui/window/wizard.py index 8da26f6ac7..081e5dbb28 100644 --- a/tryton/gui/window/wizard.py +++ b/tryton/gui/window/wizard.py @@ -167,6 +167,7 @@ class Wizard(object): self.screen = Screen(view['model'], mode=[], context=self.context) self.screen.add_view(view) + self.screen.switch_view() self.screen.widget.show() self.screen.signal_connect(self, 'record-modified', self._record_modified)