コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
14032 ビュー

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


アバター
破棄
最善の回答

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)


アバター
破棄
著作者

Exactly what I was looking for

Thank you

関連投稿 返信 ビュー 活動
0
3月 15
3891
2
10月 23
965
0
4月 24
3499
4
5月 19
12377
0
6月 21
8263