Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
14167 Zobrazení

How to get selection value translated in python code

_name = 'pos.session'

POS_SESSION_STATE = [
    ('opening_control', 'Opening Control'),
    ('opened', 'In Progress'),
    ('closing_control', 'Closing Control'),
    ('closed', 'Closed & Posted'),
]

state = fields.Selection(
    POS_SESSION_STATE, string='Status',
    required=True, readonly=True,
    index=True, copy=False, default='opening_control')

When I do a print in python code the state value returns me translated as the qweb reports


Avatar
Zrušit
Nejlepší odpověď

Hi David,

If you want to get the translation of the value, you could try something like this:

dict(self._fields['state']._description_selection(self.env)).get(self.state)


Avatar
Zrušit
Autor

Exactly what I was looking for

Thank you

Related Posts Odpovědi Zobrazení Aktivita
0
bře 15
3970
2
říj 23
1027
0
dub 24
3609
4
kvě 19
12521
0
čvn 21
8373