Se rendre au contenu
Menu
Cette question a été signalée
1 Répondre
10436 Vues

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
Ignorer
Auteur Meilleure réponse

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

Avatar
Ignorer
Publications associées Réponses Vues Activité
2
oct. 23
6482
2
nov. 22
6870
0
sept. 21
2974
4
août 20
7779
2
mars 20
11668