Add item in selection field


#1

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


(Maxime Richez) #2

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)

(Sergi Almacellas Abellana) #3

@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__()

(Korbinian Preisler) #4

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.


#5

Hi,

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


(system) closed #6

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