'Recursively get fields for the provided model (through
fields_get) and filter them according to importability
The output format is a list of ``Field``, with ``Field``
defined as:
.. class:: Field
.. attribute:: id (str)
A non-unique identifier for the field, used to compute
the span of the ``required`` attribute: if multiple
``required`` fields have the same id, only one of them
is necessary.
.. attribute:: name (str)
The field\'s logical (Odoo) name within the scope of
its parent.
.. attribute:: string (str)
The field\'s human-readable name (``@string``)
.. attribute:: required (bool)
Whether the field is marked as required in the
model. Clients must provide non-empty import values
for all required fields or the import will error out.
.. attribute:: fields (list(Field))
The current field\'s subfields. The database and
external identifiers for m2o and m2m fields; a
filtered and transformed fields_get for o2m fields (to
a variable depth defined by ``depth``).
Fields with no sub-fields will have an empty list of
sub-fields.
:param str model: name of the model to get fields form
:param int landing: depth of recursion into o2m fields'

@api.model
def get_fields(self, model, depth=FIELDS_RECURSION_LIMIT):

    Model = self.env[model]
    importable_fields = [{'id': 'id', 'name': 'id', 'string': _('External    ID'), 'required': False, 'fields': [], 'type': 'id'}]
    model_fields = Model.fields_get()
    blacklist = (models.MAGIC_COLUMNS + [Model.CONCURRENCY_CHECK_FIELD])
    for (name, field) in model_fields.iteritems():
        if (name in blacklist):
            continue
        if (field.get('deprecated', False) is not False):
            continue
        if field.get('readonly'):
            states = field.get('states')
            if (not states):
                continue
            if (not any((((attr == 'readonly') and (value is False)) for (attr, value) in itertools.chain.from_iterable(states.itervalues())))):
                continue
        field_value = {'id': name, 'name': name, 'string': field['string'], 'required': bool(field.get('required')), 'fields': [], 'type': field['type']}
        if (field['type'] in ('many2many', 'many2one')):
            field_value['fields'] = [dict(field_value, name='id', string=_('External    ID'), type='id'), dict(field_value, name='.id', string=_('Database    ID'), type='id')]
        elif ((field['type'] == 'one2many') and depth):
            field_value['fields'] = self.get_fields(field['relation'], depth=(depth - 1))
            if self.user_has_groups('base.group_no_one'):
                field_value['fields'].append({'id': '.id', 'name': '.id', 'string': _('Database    ID'), 'required': False, 'fields': [], 'type': 'id'})
        importable_fields.append(field_value)
    return importable_fields
