Skip to Content
Menu
This question has been flagged
1 Reply
2748 Views

I make a selection field that [('1','a'),('2','b'),('3','c')]

when I reference this field it comes out 1,2,3

how can I make it to show a,b,c instead of 1,2,3?

Avatar
Discard
Best Answer

You need to access the selection field .selection value and search for the display value. You could define a function in a parser to do that. This should help

<pre>


    def __init__(self, cr, uid, name, context):

        super(report, self).__init__(cr, uid, name, context=context)

        self.localcontext.update({ 

             'get_selection_value': self._get_selection_value, 

        })

    def _get_selection_value(self, model, field, value):

        selection = self.pool.get(model)._columns.get(field).selection

        val = ''

        for v in selection:

            if v[0] == value:

            val = v[1]

            break

        return val

<pre>

Avatar
Discard