コード例 #1
0
ファイル: form.py プロジェクト: kret0s/gnuhealth-live
 def display(self):
     record = self.screen.current_record
     if record:
         # Force to set fields in record
         # Get first the lazy one to reduce number of requests
         fields = [(name, field.attrs.get('loading', 'eager'))
                 for name, field in record.group.fields.iteritems()]
         fields.sort(key=operator.itemgetter(1), reverse=True)
         for field, _ in fields:
             record[field].get(record)
     focused_widget = find_focused_child(self.widget)
     for name, widgets in self.widgets.iteritems():
         field = None
         if record:
             field = record.group.fields.get(name)
         if field:
             field.state_set(record)
         for widget in widgets:
             widget.display(record, field)
     for widget in self.state_widgets:
         widget.state_set(record)
     if focused_widget:
         invisible_ancestor = get_invisible_ancestor(focused_widget)
         if invisible_ancestor:
             new_focused_widget = next_focus_widget(invisible_ancestor)
             if new_focused_widget:
                 new_focused_widget.grab_focus()
     return True
コード例 #2
0
 def display(self):
     record = self.record
     if record:
         # Force to set fields in record
         # Get first the lazy one from the view to reduce number of requests
         fields = ((name, field.attrs.get('loading', 'eager') == 'eager',
                    len(field.views))
                   for name, field in record.group.fields.items()
                   if self.view_id in field.views)
         fields = sorted(fields, key=operator.itemgetter(1, 2))
         for field, _, _ in fields:
             record[field].get(record)
     focused_widget = find_focused_child(self.widget)
     for name, widgets in self.widgets.items():
         field = None
         if record:
             field = record.group.fields.get(name)
         if field:
             field.state_set(record)
         for widget in widgets:
             widget.display()
     for widget in self.state_widgets:
         widget.state_set(record)
     if focused_widget:
         invisible_ancestor = get_invisible_ancestor(focused_widget)
         if invisible_ancestor:
             new_focused_widget = next_focus_widget(invisible_ancestor)
             if new_focused_widget:
                 new_focused_widget.grab_focus()
     return True
コード例 #3
0
ファイル: form.py プロジェクト: webmavilchez/tryton
 def display(self):
     record = self.screen.current_record
     if record:
         # Force to set fields in record
         # Get first the lazy one to reduce number of requests
         fields = [(name, field.attrs.get('loading', 'eager'))
                 for name, field in record.group.fields.iteritems()]
         fields.sort(key=operator.itemgetter(1), reverse=True)
         for field, _ in fields:
             record[field].get(record)
     focused_widget = find_focused_child(self.widget)
     for name, widgets in self.widgets.iteritems():
         field = None
         if record:
             field = record.group.fields.get(name)
         if field:
             field.state_set(record)
         for widget in widgets:
             widget.display(record, field)
     for widget in self.state_widgets:
         widget.state_set(record)
     if focused_widget:
         invisible_ancestor = get_invisible_ancestor(focused_widget)
         if invisible_ancestor:
             new_focused_widget = next_focus_widget(invisible_ancestor)
             if new_focused_widget:
                 new_focused_widget.grab_focus()
     return True
コード例 #4
0
 def display(self, force=False):
     record = self.record
     if record:
         # Force to set fields in record
         # Get first the lazy one from the view to reduce number of requests
         fields2set = set()
         for name in self.widgets:
             field = record.group.fields[name]
             fields2set.add(name)
             fields2set.update(f for f in field.attrs.get('depends', [])
                               if (not f.startswith('_parent')
                                   and f in record.group.fields))
         fields = []
         for name in fields2set:
             field = record.group.fields[name]
             fields.append((name, field.attrs.get('loading',
                                                  'eager') == 'eager',
                            len(field.views)))
         fields = sorted(fields, key=operator.itemgetter(1, 2))
         for field, _, _ in fields:
             record[field].get(record)
     focused_widget = find_focused_child(self.widget)
     for name, widgets in self.widgets.items():
         field = None
         if record:
             field = record.group.fields.get(name)
         if field:
             field.state_set(record)
         for widget in widgets:
             widget.display()
     for widget in self.state_widgets:
         widget.state_set(record)
     if focused_widget:
         invisible_ancestor = get_invisible_ancestor(focused_widget)
         if invisible_ancestor:
             new_focused_widget = next_focus_widget(invisible_ancestor)
             if new_focused_widget:
                 new_focused_widget.grab_focus()
     return True