Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
1 Ответить
10580 Представления

I want to get the value of a field in a model, by passing the field name as string to a function, for that I defined a function inside the model like:

def get_value(self, key):
    key = key.replace('_', '.')
return self.__dict__.get('_prefetch').get(key)

my question is, is there a predefined function in odoo models that can do that, if not, how can I do that in a more pythonic way 

Аватар
Отменить
Автор Лучший ответ

recordset['field_name'] or recordset.__getitem__() seems to be working fine, and they are more pythonic way to do what's needed

Аватар
Отменить
Related Posts Ответы Просмотры Активность
2
окт. 23
6702
2
нояб. 22
7138
0
сент. 21
3184
4
авг. 20
8052
2
мар. 20
11998