How can I get label names for fields in any model?
For example writing this:
obj = self.read(cr,uid,ids)[0]
It will get dictionary of fields names (technical names, or in database column names) and their values in a given record.
So for example output would be something like this:
{'field1': 10, 'field2': 'hello', 'field3': 3.56}
But it does not return labels of fields, and I can't access it from here too, because field names here is just a string.
So let say there would be these fields mentioned above:
_columns = {
'field1': fields.integer('First Field'),
'field2': fields.char('Second Field', size=128),
'field3': fields.float('Third Field'),
}
Then how could I get this instead (I know exact output is not possible, because label is not the key, but I'm just showing it to better understand the problem):
{'First Field': 10, 'Second Field': 'hello', 'Third Field': 3.56}
So I think code for retrieving labels could look something like that:
for k, v in obj.iteritems():
print k.label
But there is no such attribute. In fields.py file I saw in most field types string
named attribute is used as input for labels, which has default input string='unknown'
, but I don't get it how to retrieve it while iterating over all fields in a model.
Anyone know how to do it?
P.S. Why I need this? I need to find fields whose values meet specific condition and then write that field label in other table. I could write column name, but simple users will need to see that data, so they need to understand what that field means,, thats why I need to retrieve field labels.