本文整理汇总了Python中tryton.gui.window.view_form.screen.Screen.save_tree_state方法的典型用法代码示例。如果您正苦于以下问题:Python Screen.save_tree_state方法的具体用法?Python Screen.save_tree_state怎么用?Python Screen.save_tree_state使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tryton.gui.window.view_form.screen.Screen
的用法示例。
在下文中一共展示了Screen.save_tree_state方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Many2Many
# 需要导入模块: from tryton.gui.window.view_form.screen import Screen [as 别名]
# 或者: from tryton.gui.window.view_form.screen.Screen import save_tree_state [as 别名]
#.........这里部分代码省略.........
def _sig_remove(self, *args):
self.screen.remove(remove=True)
def _on_activate(self):
self._sig_edit()
def _sig_edit(self):
if self.screen.current_record:
def callback(result):
if result:
self.screen.current_record.save()
else:
self.screen.current_record.cancel()
WinForm(self.screen, callback)
def _readonly_set(self, value):
self._readonly = value
self._set_button_sensitive()
def _set_button_sensitive(self):
if self.record and self.field:
field_size = self.record.expr_eval(self.attrs.get('size'))
m2m_size = len(self.field.get_eval(self.record))
size_limit = (field_size is not None
and m2m_size >= field_size >= 0)
else:
size_limit = False
self.wid_text.set_sensitive(not self._readonly)
self.but_add.set_sensitive(bool(
not self._readonly
and not size_limit))
self.but_remove.set_sensitive(bool(
not self._readonly
and self._position))
def _sig_label(self, screen, signal_data):
self._position = signal_data[0]
self._set_button_sensitive()
def display(self, record, field):
super(Many2Many, self).display(record, field)
if field is None:
self.screen.new_group()
self.screen.current_record = None
self.screen.parent = True
self.screen.display()
return False
new_group = field.get_client(record)
if id(self.screen.group) != id(new_group):
self.screen.group = new_group
self.screen.display()
return True
def set_value(self, record, field):
self.screen.save_tree_state()
self.screen.current_view.set_value()
return True
def _completion_match_selected(self, completion, model, iter_):
record_id, = model.get(iter_, 1)
self.screen.load([record_id], modified=True)
self.wid_text.set_text('')
self.wid_text.grab_focus()
completion_model = self.wid_completion.get_model()
completion_model.clear()
completion_model.search_text = self.wid_text.get_text()
return True
def _update_completion(self, widget):
if self._readonly:
return
if not self.record:
return
model = self.attrs['relation']
update_completion(self.wid_text, self.record, self.field, model)
def _completion_action_activated(self, completion, index):
if index == 0:
self._sig_add(win_search=True)
self.wid_text.grab_focus()
elif index == 1:
model = self.attrs['relation']
domain = self.field.domain_get(self.record)
context = self.field.context_get(self.record)
screen = Screen(model, domain, context=context, mode=['form'])
def callback(result):
self.focus_out = True
if result:
record = screen.current_record
self.screen.load([record.id], modified=True)
self.wid_text.set_text('')
self.wid_text.grab_focus()
self.focus_out = False
WinForm(screen, callback, new=True, save_current=True)
示例2: One2Many
# 需要导入模块: from tryton.gui.window.view_form.screen import Screen [as 别名]
# 或者: from tryton.gui.window.view_form.screen.Screen import save_tree_state [as 别名]
#.........这里部分代码省略.........
def _focus_out(self, *args):
if self.wid_text.get_text():
self._sig_add()
def _sig_add(self, *args):
self.view.set_value()
domain = self.field.domain_get(self.record)
context = self.field.context_get(self.record)
domain = domain[:]
domain.extend(self.record.expr_eval(self.attrs.get('add_remove')))
removed_ids = self.field.get_removed_ids(self.record)
try:
if self.wid_text.get_text():
dom = [('rec_name', 'ilike',
'%' + self.wid_text.get_text() + '%'),
['OR', domain, ('id', 'in', removed_ids)]]
else:
dom = ['OR', domain, ('id', 'in', removed_ids)]
ids = RPCExecute('model', self.attrs['relation'], 'search', dom,
0, CONFIG['client.limit'], None, context=context)
except RPCException:
return False
def callback(result):
if result:
ids = [x[0] for x in result]
self.screen.load(ids, modified=True)
self.screen.display(res_id=ids[0])
self.screen.set_cursor()
self.wid_text.set_text('')
if len(ids) != 1:
WinSearch(self.attrs['relation'], callback, sel_multi=True,
ids=ids, context=context, domain=domain,
view_ids=self.attrs.get('view_ids', '').split(','),
views_preload=self.attrs.get('views', {}))
else:
callback([(i, None) for i in ids])
def _sig_label(self, screen, signal_data):
name = '_'
if signal_data[0] >= 1:
name = str(signal_data[0])
self.but_open.set_sensitive(True)
self.but_del.set_sensitive(not self._readonly)
if self.attrs.get('add_remove'):
self.but_remove.set_sensitive(not self._readonly)
if signal_data[0] < signal_data[1]:
self.but_next.set_sensitive(True)
else:
self.but_next.set_sensitive(False)
if signal_data[0] > 1:
self.but_pre.set_sensitive(True)
else:
self.but_pre.set_sensitive(False)
self.but_del.set_sensitive(not self._readonly)
self.but_undel.set_sensitive(not self._readonly)
else:
self.but_open.set_sensitive(False)
self.but_del.set_sensitive(False)
self.but_undel.set_sensitive(False)
self.but_next.set_sensitive(False)
self.but_pre.set_sensitive(False)
if self.attrs.get('add_remove'):
self.but_remove.set_sensitive(False)
line = '(%s/%s)' % (name, signal_data[1])
self.label.set_text(line)
def display(self, record, field):
super(One2Many, self).display(record, field)
if field is None:
self.screen.new_group()
self.screen.current_record = None
self.screen.parent = True
self.screen.display()
return False
new_group = field.get_client(record)
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():
self.screen.current_record = None
readonly = False
domain = []
if record:
readonly = field.get_state_attrs(record).get('readonly', False)
domain = field.domain_get(record)
if self.screen.domain != domain:
self.screen.domain = domain
self.screen.group.readonly = readonly
self.screen.display()
return True
def set_value(self, record, field):
self.screen.save_tree_state()
self.screen.current_view.set_value()
if self.screen.modified(): # TODO check if required
record.modified_fields.setdefault(field.name)
record.signal('record-modified')
return True
示例3: Form
# 需要导入模块: from tryton.gui.window.view_form.screen import Screen [as 别名]
# 或者: from tryton.gui.window.view_form.screen.Screen import save_tree_state [as 别名]
#.........这里部分代码省略.........
def sig_import(self, widget=None):
WinImport(self.model, self.screen.context)
def sig_save_as(self, widget=None):
export = WinExport(self.model,
[r.id for r in self.screen.selected_records],
context=self.screen.context)
for name in self.screen.current_view.get_fields():
export.sel_field(name)
def sig_new(self, widget=None, autosave=True):
if not common.MODELACCESS[self.model]['create']:
return
if autosave:
if not self.modified_save():
return
self.screen.new()
self.message_info()
self.activate_save()
def sig_copy(self, widget=None):
if not common.MODELACCESS[self.model]['create']:
return
if not self.modified_save():
return
if self.screen.copy():
self.message_info(_('Working now on the duplicated record(s).'),
gtk.MESSAGE_INFO)
def sig_save(self, widget=None):
if widget:
# Called from button so we must save the tree state
self.screen.save_tree_state()
if not (common.MODELACCESS[self.model]['write']
or common.MODELACCESS[self.model]['create']):
return
if self.screen.save_current():
self.message_info(_('Record saved.'), gtk.MESSAGE_INFO)
return True
else:
self.message_info(self.screen.invalid_message(), gtk.MESSAGE_ERROR)
return False
def sig_previous(self, widget=None):
if not self.modified_save():
return
self.screen.display_prev()
self.message_info()
self.activate_save()
def sig_next(self, widget=None):
if not self.modified_save():
return
self.screen.display_next()
self.message_info()
self.activate_save()
def sig_reload(self, test_modified=True):
if test_modified:
if not self.modified_save():
return False
else:
self.screen.save_tree_state(store=False)
self.screen.cancel_current()
set_cursor = False
示例4: Many2Many
# 需要导入模块: from tryton.gui.window.view_form.screen import Screen [as 别名]
# 或者: from tryton.gui.window.view_form.screen.Screen import save_tree_state [as 别名]
#.........这里部分代码省略.........
del self.widget
def color_set(self, name):
super(Many2Many, self).color_set(name)
widget = self._color_widget()
# if the style to apply is different from readonly then insensitive
# cellrenderers should use the default insensitive color
if name != 'readonly':
widget.modify_text(gtk.STATE_INSENSITIVE,
self.colors['text_color_insensitive'])
def _focus_out(self, *args):
if self.wid_text.get_text():
self._sig_add()
def _sig_add(self, *args):
if not self.focus_out:
return
domain = self.field.domain_get(self.record)
context = self.field.context_get(self.record)
value = self.wid_text.get_text()
self.focus_out = False
try:
if value:
dom = [('rec_name', 'ilike', '%' + value + '%'), domain]
else:
dom = domain
ids = RPCExecute('model', self.attrs['relation'], 'search',
dom, 0, CONFIG['client.limit'], None, context=context)
except RPCException:
self.focus_out = True
return False
def callback(result):
self.focus_out = True
if result:
ids = [x[0] for x in result]
self.screen.load(ids, modified=True)
self.screen.display(res_id=ids[0])
self.screen.set_cursor()
self.wid_text.set_text('')
if len(ids) != 1 or not value:
WinSearch(self.attrs['relation'], callback, sel_multi=True,
ids=ids, context=context, domain=domain,
view_ids=self.attrs.get('view_ids', '').split(','),
views_preload=self.attrs.get('views', {}))
else:
callback([(i, None) for i in ids])
def _sig_remove(self, *args):
self.screen.remove(remove=True)
def _sig_activate(self, *args):
self._sig_add()
self.wid_text.grab_focus()
def _on_activate(self):
self._sig_edit()
def _sig_edit(self):
if self.screen.current_record:
def callback(result):
if result:
self.screen.current_record.save()
else:
self.screen.current_record.cancel()
WinForm(self.screen, callback)
def _readonly_set(self, value):
self._readonly = value
self.wid_text.set_editable(not value)
self.wid_text.set_sensitive(not value)
self.but_remove.set_sensitive(not value)
self.but_add.set_sensitive(not value)
def _sig_label(self, screen, signal_data):
if signal_data[0] >= 1:
self.but_remove.set_sensitive(not self._readonly)
else:
self.but_remove.set_sensitive(False)
def display(self, record, field):
super(Many2Many, self).display(record, field)
if field is None:
self.screen.new_group()
self.screen.current_record = None
self.screen.parent = True
self.screen.display()
return False
new_group = field.get_client(record)
if id(self.screen.group) != id(new_group):
self.screen.group = new_group
self.screen.display()
return True
def set_value(self, record, field):
self.screen.save_tree_state()
self.screen.current_view.set_value()
return True