Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
14188 Widoki

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


Awatar
Odrzuć
Najlepsza odpowiedź

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)


Awatar
Odrzuć
Autor

Exactly what I was looking for

Thank you

Powiązane posty Odpowiedzi Widoki Czynność
0
mar 15
3993
2
paź 23
1037
0
kwi 24
3636
4
maj 19
12540
0
cze 21
8387