Add icon in tryton?

hello everyone, I have a query: I am developing a module in tryton and I can’t get icons to be displayed (apart from those that tryton already has), I have downloaded images in svg and it still doesn’t work.
Does anybody have any suggestions?

You must put the icon in the module (ex: icons folder) and register it with a ir.ui.icon record using XML (setting a name and a path).

1 Like

Here you have an example on how an icon is registered in sale module.

1 Like

thanks you for you example.I would also like to be able to distinguish these states with icons:
This is the code I developed, however I can’t get it to display. I must specify path too?

subscriber_quality = fields.Function(
    fields.Selection([
            (‘debt_free_subscriber’, ‘Debt Free Subscriber’),
            (‘simple_debtor_subscriber’, ‘Simple Debtor Subscriber’),
            (‘chronic_debtor_subscriber’, ‘Chronic Debtor Subscriber’),
            ], ‘Subscriber_Quality’, sort=False),
        ‘on_change_with_subscriber_quality’,
        searcher=“search_subscriber_quality”)
subscriber_quality_icon = fields.Function(
    fields.Char(‘subscriber_quality_icon’),
    ‘get_subscriber_quality_icon’)

@fields.depends('vouchers', 'party')
def on_change_with_subscriber_quality(self, name=None):
    if self.vouchers:
        vouchers_not_paid = \
           [x for x in self.vouchers
           if x.state == 'posted'
           and x.second_due_date < date.today()]
        if len(vouchers_not_paid) == 0:
            return 'debt_free_subscriber'
        if len(vouchers_not_paid) == 1:
            return 'simple_debtor_subscriber'
        if len(vouchers_not_paid) >= 2:
            return 'chronic_debtor_subscriber'
    return None

def get_subscriber_quality_icon(self, name):
    if (self.subscriber_quality == 'debt_free_subscriber'):
        return '1'
    if (self.subscriber_quality == 'simple_debtor_subscriber'):
        return 'icon2'
    if (self.subscriber_quality == 'chronic_debtor_subscriber'):
        return 'icon3'

On get_subscriber_quality_icon you should return the name of the icon to be used, for example tryton-sale if you want to use the icon registered by sale module

1 Like