Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
13991 Vizualizări

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


Imagine profil
Abandonează
Cel mai bun răspuns

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)


Imagine profil
Abandonează
Autor

Exactly what I was looking for

Thank you

Related Posts Răspunsuri Vizualizări Activitate
0
mar. 15
3839
2
oct. 23
925
0
apr. 24
3416
4
mai 19
12337
0
iun. 21
8205