Exemplo n.º 1
0
 def edit(menuitem):
     with Window(hide_current=True, allow_similar=True):
         Window.create(model,
                       view_ids=field.attrs.get('view_ids', '').split(','),
                       res_id=id_(record),
                       mode=['form'],
                       name=field.attrs.get('string'))
Exemplo n.º 2
0
 def _popup_menu_selected(self, menuitem, togglebutton, action, keyword):
     event = Gtk.get_current_event()
     allow_similar = False
     if (event.state & Gdk.ModifierType.CONTROL_MASK
             or event.state & Gdk.ModifierType.MOD1_MASK):
         allow_similar = True
     with Window(hide_current=True, allow_similar=allow_similar):
         self._action(action, keyword)
     togglebutton.props.active = False
Exemplo n.º 3
0
 def _action_favorite(widget, id_):
     event = gtk.get_current_event()
     allow_similar = (event.state & gtk.gdk.MOD1_MASK
                      or event.state & gtk.gdk.SHIFT_MASK)
     with Window(allow_similar=allow_similar):
         # ids is not defined to prevent to add suffix
         Action.exec_keyword('tree_open', {
             'model': self.menu_screen.model_name,
             'id': id_,
         })
Exemplo n.º 4
0
 def __sig_switch(self, treeview, path, column):
     if column._type == 'button':
         return
     allow_similar = False
     event = gtk.get_current_event()
     if (event.state & gtk.gdk.MOD1_MASK
             or event.state & gtk.gdk.SHIFT_MASK):
         allow_similar = True
     with Window(allow_similar=allow_similar):
         if not self.screen.row_activate() and self.children_field:
             if treeview.row_expanded(path):
                 treeview.collapse_row(path)
             else:
                 treeview.expand_row(path, False)
Exemplo n.º 5
0
 def activate(menuitem, action, atype):
     rec = load(record)
     data = {
         'model': model,
         'id': rec.id,
         'ids': [rec.id],
     }
     event = Gtk.get_current_event()
     allow_similar = False
     if (event.state & Gdk.ModifierType.CONTROL_MASK
             or event.state & Gdk.ModifierType.MOD1_MASK):
         allow_similar = True
     with Window(hide_current=True, allow_similar=allow_similar):
         Action.execute(action, data, context=rec.get_context())
Exemplo n.º 6
0
 def activate(menuitem, action, atype):
     rec = load(record)
     action = Action.evaluate(action, atype, rec)
     data = {
         'model': model,
         'id': rec.id,
         'ids': [rec.id],
     }
     event = gtk.get_current_event()
     allow_similar = False
     if (event.state & gtk.gdk.CONTROL_MASK
             or event.state & gtk.gdk.MOD1_MASK):
         allow_similar = True
     with Window(hide_current=True, allow_similar=allow_similar):
         Action._exec_action(action, data, rec.get_context())
Exemplo n.º 7
0
    def __call__(self, model, id_, context):
        res = super(ConcurrencyDialog, self).__call__()

        if res == Gtk.ResponseType.OK:
            return True
        if res == Gtk.ResponseType.APPLY:
            from tryton.gui.window import Window
            name = RPCExecute('model',
                              model,
                              'read', [id_], ['rec_name'],
                              context=context)[0]['rec_name']
            with Window(allow_similar=True):
                Window.create(model,
                              res_id=id_,
                              name=_("Compare: %s", name),
                              domain=[('id', '=', id_)],
                              context=context,
                              mode=['form'])
        return False
Exemplo n.º 8
0
 def action_keyword(self, ids):
     if not ids:
         return
     ctx = self.group._context.copy()
     if 'active_ids' in ctx:
         del ctx['active_ids']
     if 'active_id' in ctx:
         del ctx['active_id']
     event = Gtk.get_current_event()
     allow_similar = False
     if (event.state & Gdk.ModifierType.CONTROL_MASK
             or event.state & Gdk.ModifierType.MOD1_MASK):
         allow_similar = True
     with Window(hide_current=True, allow_similar=allow_similar):
         return Action.exec_keyword('graph_open', {
                 'model': self.model,
                 'id': ids[0],
                 'ids': ids,
                 }, context=ctx, warning=False)
Exemplo n.º 9
0
    def __button_press(self, treeview, event):
        if event.button == 3:
            try:
                path, col, x, y = treeview.get_path_at_pos(
                    int(event.x), int(event.y))
            except TypeError:
                # Outside row
                return False
            menu = gtk.Menu()
            copy_item = gtk.ImageMenuItem('gtk-copy')
            copy_item.set_use_stock(True)
            copy_item.connect('activate', lambda x: self.on_copy())
            menu.append(copy_item)
            if self.editable:
                paste_item = gtk.ImageMenuItem('gtk-paste')
                paste_item.set_use_stock(True)
                paste_item.connect('activate', lambda x: self.on_paste())
                menu.append(paste_item)
            menu.show_all()
            menu.popup(None, None, None, event.button, event.time)

            def pop(menu, group, record):
                # Don't activate actions if parent is modified
                parent = record.parent if record else None
                while parent:
                    if parent.modified:
                        break
                    parent = parent.parent
                else:
                    populate(menu, group.model_name, record)
                for col in self.treeview.get_columns():
                    if not col.get_visible() or not col.name:
                        continue
                    field = group.fields[col.name]
                    model = None
                    if field.attrs['type'] == 'many2one':
                        model = field.attrs['relation']
                        record_id = field.get(record)
                    elif field.attrs['type'] == 'reference':
                        value = field.get(record)
                        if value:
                            model, record_id = value.split(',')
                            record_id = int(record_id)
                    if not model:
                        continue
                    label = field.attrs['string']
                    context = field.get_context(record)
                    populate(menu,
                             model,
                             record_id,
                             title=label,
                             field=field,
                             context=context)
                menu.show_all()

            selection = treeview.get_selection()
            if selection.count_selected_rows() == 1:
                group = self.screen.group
                if selection.get_mode() == gtk.SELECTION_SINGLE:
                    model = selection.get_selected()[0]
                elif selection.get_mode() == gtk.SELECTION_MULTIPLE:
                    model = selection.get_selected_rows()[0]
                record = model.get_value(model.get_iter(path), 0)
                # Delay filling of popup as it can take time
                gobject.idle_add(pop, menu, group, record)
            return True  # Don't change the selection
        elif event.button == 2:
            with Window(allow_similar=True):
                self.screen.row_activate()
            return True
        return False
Exemplo n.º 10
0
 def edit(menuitem):
     with Window(hide_current=True, allow_similar=True):
         Window.create(field.attrs.get('view_ids'),
                       model,
                       id_(record),
                       mode=['form'])