Added lookup-recs command

This commit is contained in:
DiG 2022-01-16 16:23:48 +01:00
parent 951e799c59
commit eba38719e0
1 changed files with 26 additions and 3 deletions

View File

@ -238,7 +238,7 @@ def lookup_model( muid ):
inst = odoo.env[model].browse( id )
except:
_tree[muid]['error'] = 'Instance %s not found' % (muid)
return [ _tree ]
return _tree
# data = inst.read()[0]
# size = len( json.dumps(data, indent=4) )
# filename = json_path( model, inst.id )
@ -268,7 +268,27 @@ def lookup_model( muid ):
else:
_tree[muid]['error'] = 'Model do not exists'
return [ _tree ]
return _tree
def lookup_recs( model, domains ):
eprint( "> Lookup recusif: %s %s" % (model,domains) )
if model in MODEL_IGNORE:
eprint( 'IGNORED' )
return
Model = odoo.env[model]
ids = Model.search( domains )
# rfields = rel_fields( model )
# eprint( rfields )
for inst in Model.browse( ids ):
tree = lookup( Muid(model, inst.id) )
filename = json_path( model, inst.id )
if filename in [item['file'] for item in stack]:
continue
tree['file'] = filename
# stack.append({ 'model': model, 'id': inst.id, 'file': filename, 'data': size })
stack.append( tree )
def lookup( model, domains ):
eprint( "> Lookup: %s %s" % (model,domains) )
@ -413,9 +433,12 @@ if MODEL in odoo.env:
if METHOD == 'lookup':
print( lookup( MODEL, args2domains(PARAMS[2:]) ) )
if METHOD == 'lookup_model':
if METHOD == 'lookup-model':
jlog( lookup_model( Muid(MODEL,PARAMS[2]) ) )
if METHOD == 'lookup-recs':
jlog( lookup_recs( MODEL, args2domains(PARAMS[2:]) )
if METHOD == 'export-json':
export_json( MODEL, args2domains(PARAMS[2:]) )