1

I have a selection field and I want to print the selected value but I got the key.

Python code:

'transport': fields.selection([('plain','Plain'),
                               ('train','Train'),
                               ('taxi','Taxi'),
                               ('bus','Bus'), 
                               ('sv','Service vehicle')],'Means of transport'),

RML:

[[ o.transport or '']]

When I select Plain the printed value is plain.

How to get Plain in the printed report instead of plain?

Kenly
  • 24,317
  • 7
  • 44
  • 60

1 Answers1

0

We may achieve in two ways.

  1. Direct condition on .rml and
  2. Using function

Direct condition on .rml

For example:

[[ o.transport == 'avion' and 'Avion' or o.transport == 'train' and 'Train' ]] 

Using function

We need to add function on report .py file

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

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

    res = ''

    for v in selection:

        if v[0] == value:

            res = v[1]

        break

    return res
Bhavesh Odedra
  • 10,990
  • 12
  • 33
  • 58