Skip to Content
Menu
This question has been flagged
1 Reply
9446 Views

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 

Avatar
Discard
Author Best Answer

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

Avatar
Discard
Related Posts Replies Views Activity
2
Oct 23
4748
2
Nov 22
5159
0
Sep 21
1773
4
Aug 20
6579
2
Mar 20
9691