Add item in selection field

Hi,

I need to add an item to an existing selection field. I override the class in my module and i put the section field with my adds in it, but when update the database my add isn’t visible ??
This is not the correct way ??

Regards

I’m doing this way:

class NAME(metaclass=PoolMeta):
        __name__ = "xxxx"

    @classmethod
    def __setup__(cls):
        super(ModuleName, cls).__setup__()
        selection = ('sent', 'Sent')
        if selection not in cls.field_name.selection:
            cls.field_name.selection.append(selection)

@maxx on python3 it is no longer required to specify the name and cls to super class:

You can replace:

    super(moduleName, cls).__setup__()

For:

    super().__setup__()
1 Like

You may also need to close and reopen the tab of the view with the affected field to see the new value even if you run the Tryton Client in “–dev” mode.

Hi,

@maxx : Thank you, I had forgotten this way of doing

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.