This file is indexed.

/usr/lib/python2.7/dist-packages/tryton/common/popup_menu.py is in tryton-client 3.8.4-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# This file is part of Tryton.  The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
import gtk
import gettext
from tryton.common import RPCExecute, RPCException
from tryton.gui.window.view_form.screen import Screen
from tryton.action import Action
from tryton.gui.window import Window
from tryton.gui.window.attachment import Attachment

_ = gettext.gettext


def populate(menu, model, record, title='', field=None):
    '''
    Fill menu with the actions of model for the record.
    If title is filled, the actions will be put in a submenu.
    '''
    if record is None:
        return
    elif isinstance(record, (int, long)):
        if record < 0:
            return
    elif record.id < 0:
        return

    def load(record):
        if isinstance(record, (int, long)):
            screen = Screen(model)
            screen.load([record])
            record = screen.current_record
        return record

    def id_(record):
        if not isinstance(record, (int, long)):
            return record.id
        return record

    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, {})

    def attachment(menuitem):
        Attachment(load(record), None)

    def edit(menuitem):
        with Window(hide_current=True, allow_similar=True):
            Window.create(field.attrs.get('view_ids'), model, id_(record),
                mode=['form'])

    if title:
        if len(menu):
            menu.append(gtk.SeparatorMenuItem())
        title_item = gtk.MenuItem(title)
        menu.append(title_item)
        submenu = gtk.Menu()
        title_item.set_submenu(submenu)
        action_menu = submenu
    else:
        action_menu = menu

    if len(action_menu):
        action_menu.append(gtk.SeparatorMenuItem())
    if field:
        edit_item = gtk.MenuItem(_('Edit...'))
        edit_item.connect('activate', edit)
        action_menu.append(edit_item)
        action_menu.append(gtk.SeparatorMenuItem())
    attachment_item = gtk.ImageMenuItem('tryton-attachment')
    attachment_item.set_label(_('Attachments...'))
    action_menu.append(attachment_item)
    attachment_item.connect('activate', attachment)

    def set_toolbar(toolbar):
        try:
            toolbar = toolbar()
        except RPCException:
            return
        for atype, icon, label, flavor in (
                ('action', 'tryton-executable', _('Actions...'), None),
                ('relate', 'tryton-go-jump', _('Relate...'), None),
                ('print', 'tryton-print-open', _('Report...'), 'open'),
                ('print', 'tryton-print-email', _('E-Mail...'), 'email'),
                ('print', 'tryton-print', _('Print...'), 'print'),
                ):
            if len(action_menu):
                action_menu.append(gtk.SeparatorMenuItem())
            title_item = gtk.ImageMenuItem(icon)
            title_item.set_label(label)
            action_menu.append(title_item)
            if not toolbar[atype]:
                title_item.set_sensitive(False)
                continue
            submenu = gtk.Menu()
            title_item.set_submenu(submenu)
            for action in toolbar[atype]:
                action = action.copy()
                item = gtk.MenuItem(action['name'])
                submenu.append(item)
                if flavor == 'print':
                    action['direct_print'] = True
                elif flavor == 'email':
                    action['email_print'] = True
                item.connect('activate', activate, action, atype)
            menu.show_all()
    RPCExecute('model', model, 'view_toolbar_get', callback=set_toolbar)
    menu.show_all()