تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
14011 أدوات العرض

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
مارس 15
3868
2
أكتوبر 23
934
0
أبريل 24
3477
4
مايو 19
12352
0
يونيو 21
8232