/usr/lib/python3/dist-packages/trytond/ir/ui/icon.py is in tryton-server 4.6.3-2.
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 | # 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 os
from trytond.model import ModelView, ModelSQL, fields
from trytond.tools import file_open
from trytond.transaction import Transaction
from trytond.rpc import RPC
__all__ = [
'Icon',
]
class Icon(ModelSQL, ModelView):
'Icon'
__name__ = 'ir.ui.icon'
name = fields.Char('Name', required=True, select=True)
module = fields.Char('Module', readonly=True, required=True)
path = fields.Char('SVG Path', readonly=True, required=True)
icon = fields.Function(fields.Char('Icon', depends=['path']), 'get_icon')
sequence = fields.Integer('Sequence', required=True)
@classmethod
def __setup__(cls):
super(Icon, cls).__setup__()
cls._order.insert(0, ('sequence', 'ASC'))
cls.__rpc__.update({
'list_icons': RPC(),
})
@staticmethod
def default_module():
return Transaction().context.get('module') or ''
@staticmethod
def default_sequence():
return 10
@classmethod
def list_icons(cls):
icons = {}
for icon in cls.browse(cls.search([],
order=[('sequence', 'ASC'), ('id', 'ASC')])):
if icon.name not in icons:
icons[icon.name] = icon.id
return sorted((icon_id, name) for name, icon_id in icons.items())
def get_icon(self, name):
path = os.path.join(self.module, self.path.replace('/', os.sep))
with file_open(path,
subdir='modules', mode='r', encoding='utf-8') as fp:
return fp.read()
|