remote.py as module
This commit is contained in:
parent
290dd598fd
commit
9f5d2acfd3
29
remote.py
29
remote.py
|
@ -177,14 +177,14 @@ def lookup_file( muid, format ):
|
|||
|
||||
_visited = []
|
||||
|
||||
def lookup_model( muid ):
|
||||
def lookup_model( muid, recurse = False ):
|
||||
eprint( "> Lookup model: %s" % (muid) )
|
||||
recursive = False
|
||||
if ( 'recursive' in OPTS and OPTS['recursive'] ): # or ( 'format' in OPTS and 'json' in OPTS['format'] ):
|
||||
recursive = OPTS['recursive']
|
||||
if type(recursive) == str:
|
||||
recursive = recursive.split(',')
|
||||
eprint( "> Recursive: %s %s" % (recursive, type(recursive)) )
|
||||
# recursive = False
|
||||
# if ( 'recursive' in OPTS and OPTS['recursive'] ): # or ( 'format' in OPTS and 'json' in OPTS['format'] ):
|
||||
# recursive = OPTS['recursive']
|
||||
if type(recurse) == str:
|
||||
recurse = recurse.split(',')
|
||||
eprint( "> Recursive: %s %s" % (recurse, type(recurse)) )
|
||||
|
||||
_tree = {}
|
||||
# _ctree = _tree
|
||||
|
@ -233,7 +233,7 @@ def lookup_model( muid ):
|
|||
# if field.ttype == 'many2many':
|
||||
# if field.ttype == 'reference':
|
||||
|
||||
if recursive == True or field.relation in recursive:
|
||||
if recurse == True or field.relation in recurse:
|
||||
_tree[muid][field.name] = [ lookup_model( id ) for id in _tree[muid][field.name] ]
|
||||
|
||||
|
||||
|
@ -242,7 +242,7 @@ def lookup_model( muid ):
|
|||
|
||||
return _tree
|
||||
|
||||
def lookup( model, domains ):
|
||||
def lookup( model, domains, recurse = False ):
|
||||
eprint( "> Lookup many: %s %s" % (model,domains) )
|
||||
if model in MODEL_IGNORE:
|
||||
eprint( 'IGNORED' )
|
||||
|
@ -254,7 +254,7 @@ def lookup( model, domains ):
|
|||
|
||||
for inst in Model.browse( ids ):
|
||||
|
||||
tree = lookup_model( Muid(model, inst.id) )
|
||||
tree = lookup_model( Muid(model, inst.id), recurse=recurse )
|
||||
filename = json_path( model, inst.id )
|
||||
if filename in [item['file'] for item in stack]:
|
||||
continue
|
||||
|
@ -490,11 +490,16 @@ if __name__ == "__main__":
|
|||
#for inst in Field.browse( ids ):
|
||||
# render_tsv( 'ir.model.fields', inst )
|
||||
|
||||
if 'lookup' in METHOD:
|
||||
recurse = False
|
||||
if ( 'recurse' in OPTS and OPTS['recurse'] ):
|
||||
recurse = OPTS['recurse']
|
||||
|
||||
if METHOD == 'lookup':
|
||||
jlog( lookup( MODEL, args2domains(PARAMS[2:]) ) )
|
||||
jlog( lookup( MODEL, args2domains(PARAMS[2:]), recurse=recurse ) )
|
||||
|
||||
if METHOD == 'lookup-model':
|
||||
jlog( lookup_model( Muid(MODEL,PARAMS[2]) ) )
|
||||
jlog( lookup_model( Muid(MODEL,PARAMS[2]), recurse=recurse ) )
|
||||
|
||||
# if METHOD == 'lookup-recs':
|
||||
# jlog( lookup_recs( MODEL, args2domains(PARAMS[2:]) ) )
|
||||
|
|
Loading…
Reference in New Issue