Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
1 Beantwoorden
10415 Weergaven

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
Annuleer
Auteur Beste antwoord

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

Avatar
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
2
okt. 23
6464
2
nov. 22
6867
0
sep. 21
2970
4
aug. 20
7778
2
mrt. 20
11657