Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
2934 Lượt xem

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?

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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>

Ảnh đại diện
Huỷ bỏ