From 53685c3b269ed1a83cdd00a055484394b6d4dd2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 2 Jun 2008 12:37:51 +0200 Subject: [PATCH] Fix set_cursor if there is not model --- tryton/gui/window/view_form/view/form.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/tryton/gui/window/view_form/view/form.py b/tryton/gui/window/view_form/view/form.py index f473038972..24003bec86 100644 --- a/tryton/gui/window/view_form/view/form.py +++ b/tryton/gui/window/view_form/view/form.py @@ -205,15 +205,16 @@ class ViewForm(ParserView): model = self.screen.current_model position = len(self.widgets) focus_widget = None - for widget in self.widgets.values(): - modelfield = model.mgroup.mfields.get(widget.widget_name, None) - if not modelfield: - continue - if not modelfield.get_state_attrs(model).get('valid', True): - if widget.widget.position >= position: + if model: + for widget in self.widgets.values(): + modelfield = model.mgroup.mfields.get(widget.widget_name, None) + if not modelfield: continue - position = widget.widget.position - focus_widget = widget + if not modelfield.get_state_attrs(model).get('valid', True): + if widget.widget.position >= position: + continue + position = widget.widget.position + focus_widget = widget if focus_widget: for notebook in self.notebooks: for i in range(notebook.get_n_pages()):