Added lookup-recs command
This commit is contained in:
parent
951e799c59
commit
eba38719e0
29
odoo-rpc.py
29
odoo-rpc.py
|
@ -238,7 +238,7 @@ def lookup_model( muid ):
|
||||||
inst = odoo.env[model].browse( id )
|
inst = odoo.env[model].browse( id )
|
||||||
except:
|
except:
|
||||||
_tree[muid]['error'] = 'Instance %s not found' % (muid)
|
_tree[muid]['error'] = 'Instance %s not found' % (muid)
|
||||||
return [ _tree ]
|
return _tree
|
||||||
# data = inst.read()[0]
|
# data = inst.read()[0]
|
||||||
# size = len( json.dumps(data, indent=4) )
|
# size = len( json.dumps(data, indent=4) )
|
||||||
# filename = json_path( model, inst.id )
|
# filename = json_path( model, inst.id )
|
||||||
|
@ -268,7 +268,27 @@ def lookup_model( muid ):
|
||||||
else:
|
else:
|
||||||
_tree[muid]['error'] = 'Model do not exists'
|
_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 ):
|
def lookup( model, domains ):
|
||||||
eprint( "> Lookup: %s %s" % (model,domains) )
|
eprint( "> Lookup: %s %s" % (model,domains) )
|
||||||
|
@ -413,9 +433,12 @@ if MODEL in odoo.env:
|
||||||
if METHOD == 'lookup':
|
if METHOD == 'lookup':
|
||||||
print( lookup( MODEL, args2domains(PARAMS[2:]) ) )
|
print( lookup( MODEL, args2domains(PARAMS[2:]) ) )
|
||||||
|
|
||||||
if METHOD == 'lookup_model':
|
if METHOD == 'lookup-model':
|
||||||
jlog( lookup_model( Muid(MODEL,PARAMS[2]) ) )
|
jlog( lookup_model( Muid(MODEL,PARAMS[2]) ) )
|
||||||
|
|
||||||
|
if METHOD == 'lookup-recs':
|
||||||
|
jlog( lookup_recs( MODEL, args2domains(PARAMS[2:]) )
|
||||||
|
|
||||||
if METHOD == 'export-json':
|
if METHOD == 'export-json':
|
||||||
export_json( MODEL, args2domains(PARAMS[2:]) )
|
export_json( MODEL, args2domains(PARAMS[2:]) )
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue