Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
1 Beantwoorden
13992 Weergaven

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
Annuleer
Beste antwoord

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
Annuleer
Auteur

Exactly what I was looking for

Thank you

Gerelateerde posts Antwoorden Weergaven Activiteit
0
mrt. 15
3841
2
okt. 23
925
0
apr. 24
3423
4
mei 19
12338
0
jun. 21
8206