How to find function fields and related fields in a model using introspection?

Asked by Numérigraphe

Using the object "res.model", we can easily find out which fields a model object is composed of, but the "ttype" that can be read for function fields and related fields is the type of the returned value, so that we don't know whether the field is a normal field or not.
Please, how can I determine is a field is a normal data field or a calculated field?
Thanks in advance,
Lionel Sausin.

Question information

Language:
English Edit question
Status:
Solved
For:
Odoo Server (MOVED TO GITHUB) Edit question
Assignee:
No assignee Edit question
Solved by:
Stefan Rijnhart (Opener)
Solved:
Last query:
Last reply:
Revision history for this message
Best Stefan Rijnhart (Opener) (stefan-opener) said :
#1

Hi Lionel,

this information is not encoded in the database. You will have to check the instantiated model's column types

isinstance(model._columns[field], osv.fields.related)
and
isinstance(model._columns[field], osv.fields.function)

Cheers,
Stefan.

Revision history for this message
Numérigraphe (numerigraphe) said :
#2

Thanks Stefan Rijnhart (Therp), that solved my question.