Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
1 Vastaa
10451 Näkymät

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
Hylkää
Tekijä Paras vastaus

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

Avatar
Hylkää
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
2
lokak. 23
6494
2
marrask. 22
6875
0
syysk. 21
2981
4
elok. 20
7795
2
maalisk. 20
11684