跳至内容
菜单
此问题已终结
1 回复
10414 查看

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

形象
丢弃
相关帖文 回复 查看 活动
2
10月 23
6464
2
11月 22
6867
0
9月 21
2970
4
8月 20
7778
2
3月 20
11657