WIP lookup commands

This commit is contained in:
DiG 2022-01-17 13:15:03 +01:00
parent bd01dc4fbf
commit 54ec10eb4d
1 changed files with 11 additions and 0 deletions

View File

@ -226,6 +226,8 @@ def lookup_file( muid, format ):
else:
return { 'file': filename, 'exists': True }
_visited = []
def lookup_model( muid ):
eprint( "> Lookup model: %s" % (muid) )
recursive = False
@ -241,6 +243,9 @@ def lookup_model( muid ):
id = int(id)
eprint( model, id )
_tree[muid] = {}
if muid in _visited:
_tree[muid]['error'] = 'Cyclic %s already visited' % (muid)
return _tree
# _ctree = _tree[muid]
if model in odoo.env:
@ -251,6 +256,8 @@ def lookup_model( muid ):
except:
_tree[muid]['error'] = 'Instance %s not found' % (muid)
return _tree
_visited.append( muid )
# data = inst.read()[0]
# size = len( json.dumps(data, indent=4) )
# filename = json_path( model, inst.id )
@ -276,6 +283,10 @@ def lookup_model( muid ):
# if field.ttype == 'many2many':
# if field.ttype == 'reference':
if recursive == True or field.relation in recursive:
_tree[muid][field.name] = [ lookup_model( muid ) for id in _tree[muid][field.name] ]
else:
_tree[muid]['error'] = 'Model do not exists'