WIP lookup one model
This commit is contained in:
parent
f2380522e4
commit
951e799c59
24
odoo-rpc.py
24
odoo-rpc.py
|
@ -222,27 +222,31 @@ current_exports = []
|
||||||
|
|
||||||
def lookup_model( muid ):
|
def lookup_model( muid ):
|
||||||
eprint( "> Lookup model: %s" % (muid) )
|
eprint( "> Lookup model: %s" % (muid) )
|
||||||
_stack = []
|
# _stack = []
|
||||||
_tree = {}
|
_tree = {}
|
||||||
_ctree = _tree
|
# _ctree = _tree
|
||||||
model, id = muid.split( '/' )
|
model, id = muid.split( '/' )
|
||||||
id = int(id)
|
id = int(id)
|
||||||
eprint( model, id )
|
eprint( model, id )
|
||||||
_tree[muid] = {}
|
_tree[muid] = {}
|
||||||
_ctree = _tree[muid]
|
# _ctree = _tree[muid]
|
||||||
|
|
||||||
if model in odoo.env:
|
if model in odoo.env:
|
||||||
rfields = rel_fields( model )
|
rfields = rel_fields( model )
|
||||||
eprint( rfields )
|
eprint( rfields )
|
||||||
inst = odoo.env[model].browse( id )
|
try:
|
||||||
|
inst = odoo.env[model].browse( id )
|
||||||
|
except:
|
||||||
|
_tree[muid]['error'] = 'Instance %s not found' % (muid)
|
||||||
|
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 )
|
||||||
# _ctree['size'] = size
|
# _tree[muid]['size'] = size
|
||||||
|
|
||||||
for field in rfields:
|
for field in rfields:
|
||||||
# if data[field.name]:
|
# if data[field.name]:
|
||||||
# _ctree[field.name] = {}
|
# _tree[muid][field.name] = {}
|
||||||
_value = getattr( inst, field.name )
|
_value = getattr( inst, field.name )
|
||||||
print( field.name )
|
print( field.name )
|
||||||
print( _value )
|
print( _value )
|
||||||
|
@ -251,10 +255,10 @@ def lookup_model( muid ):
|
||||||
if field.ttype == 'many2one':
|
if field.ttype == 'many2one':
|
||||||
id = _value.id
|
id = _value.id
|
||||||
# _stack.append( Muid(field.relation, id) )
|
# _stack.append( Muid(field.relation, id) )
|
||||||
_ctree[field.name] = [ Muid(field.relation, id) ]
|
_tree[muid][field.name] = [ Muid(field.relation, id) ]
|
||||||
|
|
||||||
if field.ttype == 'one2many':
|
if field.ttype == 'one2many':
|
||||||
_ctree[field.name] = [ Muid(field.relation, id) for id in _value.ids ]
|
_tree[muid][field.name] = [ Muid(field.relation, id) for id in _value.ids ]
|
||||||
# for id in _value.ids:
|
# for id in _value.ids:
|
||||||
# _stack.append( Muid(field.relation, id) )
|
# _stack.append( Muid(field.relation, id) )
|
||||||
|
|
||||||
|
@ -262,9 +266,9 @@ def lookup_model( muid ):
|
||||||
# if field.ttype == 'reference':
|
# if field.ttype == 'reference':
|
||||||
|
|
||||||
else:
|
else:
|
||||||
_ctree['error'] = 'Model do not exists'
|
_tree[muid]['error'] = 'Model do not exists'
|
||||||
|
|
||||||
return _tree
|
return [ _tree ]
|
||||||
|
|
||||||
def lookup( model, domains ):
|
def lookup( model, domains ):
|
||||||
eprint( "> Lookup: %s %s" % (model,domains) )
|
eprint( "> Lookup: %s %s" % (model,domains) )
|
||||||
|
|
Loading…
Reference in New Issue