Do not validate non editable views when switching

review1140002
This commit is contained in:
Nicolas Évrard committed 2013-10-18 17:11:40 +02:00
1 parent d1c0ecbbfd
commit ee77f32701
6 files changed
+15 -25

No files matched your search

+2 -13
View File
@@ -357,7 +357,7 @@ class Screen(SignalEvent):
self.current_record not in self.current_record.group):
self.current_record = None
fields = self.current_view.get_fields()
if (self.current_record
if (self.current_record and self.current_view.editable
and not self.current_record.validate(fields)):
self.screen_container.set(self.current_view.widget)
self.set_cursor()
@@ -439,22 +439,11 @@ class Screen(SignalEvent):
self.views.append(view)
return view
def editable_get(self):
if hasattr(self.current_view, 'widget_tree'):
if hasattr(self.current_view.widget_tree, 'editable'):
return self.current_view.widget_tree.editable
return False
def new(self, default=True):
previous_view = self.current_view
if self.current_view.view_type == 'calendar':
selected_date = self.current_view.get_selected_date()
if (self.current_view
and ((self.current_view.view_type == 'tree'
and not (hasattr(self.current_view.widget_tree,
'editable')
and self.current_view.widget_tree.editable))
or self.current_view.view_type in ('graph', 'calendar'))):
if self.current_view and not self.current_view.editable:
self.switch_view('form')
if self.current_view.view_type != 'form':
return None
@@ -22,6 +22,7 @@ class ViewCalendar(ParserView):
super(ViewCalendar, self).__init__(screen, widget, children, buttons,
notebooks, cursor_widget, children_field)
self.view_type = 'calendar'
self.editable = False
def __getitem__(self, name):
return None
+1
View File
@@ -18,6 +18,7 @@ class ViewForm(ParserView):
super(ViewForm, self).__init__(screen, widget, children, state_widgets,
notebooks, cursor_widget, children_field)
self.view_type = 'form'
self.editable = True
for widget in self.state_widgets:
if isinstance(widget, gtk.Button):
@@ -328,8 +328,7 @@ class One2Many(WidgetInterface):
if sequence:
self.screen.group.set_sequence(field=sequence)
if (self.screen.current_view.view_type == 'form') \
or self.screen.editable_get():
if self.screen.current_view.editable:
self.screen.new()
self.screen.current_view.widget.set_sensitive(True)
update_sequence()
@@ -448,7 +447,7 @@ class One2Many(WidgetInterface):
if id(self.screen.group) != id(new_group):
self.screen.group = new_group
if (self.screen.current_view.view_type == 'tree') \
and self.screen.editable_get():
and self.screen.current_view.editable:
self.screen.current_record = None
readonly = False
domain = []
@@ -11,6 +11,7 @@ class ViewGraph(ParserView):
state_widgets, notebooks, cursor_widget, children_field)
self.view_type = 'graph'
self.widgets = children
self.editable = False
def __getitem__(self, name):
return None
+8 -9
View File
@@ -333,6 +333,10 @@ class ViewList(ParserView):
def modified(self):
return False
@property
def editable(self):
return bool(getattr(self.widget_tree, 'editable', False))
def get_fields(self):
return [col.name for col in self.widget_tree.get_columns() if col.name]
@@ -447,8 +451,7 @@ class ViewList(ParserView):
return
def on_paste(self):
if (not hasattr(self.widget_tree, 'editable')
or not self.widget_tree.editable):
if not self.editable:
return
def unquote(value):
@@ -756,9 +759,7 @@ class ViewList(ParserView):
else:
self.screen.current_record = None
if (hasattr(self.widget_tree, 'editable')
and self.widget_tree.editable
and previous_record):
if self.editable and previous_record:
def go_previous():
self.screen.current_record = previous_record
self.set_cursor()
@@ -787,8 +788,7 @@ class ViewList(ParserView):
self.update_children()
def set_value(self):
if hasattr(self.widget_tree, 'editable') \
and self.widget_tree.editable:
if self.editable:
self.widget_tree.set_value()
def reset(self):
@@ -811,8 +811,7 @@ class ViewList(ParserView):
if self.store:
self.widget_tree.set_model(self.store)
self.widget_tree.queue_draw()
if hasattr(self.widget_tree, 'editable') \
and self.widget_tree.editable:
if self.editable:
self.set_state()
self.update_children()