WIP lookup one model
This commit is contained in:
parent
8a8c91e00e
commit
f2380522e4
21
odoo-rpc.py
21
odoo-rpc.py
|
@ -223,9 +223,13 @@ current_exports = []
|
|||
def lookup_model( muid ):
|
||||
eprint( "> Lookup model: %s" % (muid) )
|
||||
_stack = []
|
||||
_tree = {}
|
||||
_ctree = _tree
|
||||
model, id = muid.split( '/' )
|
||||
id = int(id)
|
||||
eprint( model, id )
|
||||
_tree[muid] = {}
|
||||
_ctree = _tree[muid]
|
||||
|
||||
if model in odoo.env:
|
||||
rfields = rel_fields( model )
|
||||
|
@ -234,9 +238,11 @@ def lookup_model( muid ):
|
|||
# data = inst.read()[0]
|
||||
# size = len( json.dumps(data, indent=4) )
|
||||
# filename = json_path( model, inst.id )
|
||||
# _ctree['size'] = size
|
||||
|
||||
for field in rfields:
|
||||
# if data[field.name]:
|
||||
# _ctree[field.name] = {}
|
||||
_value = getattr( inst, field.name )
|
||||
print( field.name )
|
||||
print( _value )
|
||||
|
@ -244,16 +250,21 @@ def lookup_model( muid ):
|
|||
print( field.name, field.ttype )
|
||||
if field.ttype == 'many2one':
|
||||
id = _value.id
|
||||
_stack.append( Muid(field.relation, id) )
|
||||
# _stack.append( Muid(field.relation, id) )
|
||||
_ctree[field.name] = [ Muid(field.relation, id) ]
|
||||
|
||||
if field.ttype == 'one2many':
|
||||
for id in _value.ids:
|
||||
_stack.append( Muid(field.relation, id) )
|
||||
_ctree[field.name] = [ Muid(field.relation, id) for id in _value.ids ]
|
||||
# for id in _value.ids:
|
||||
# _stack.append( Muid(field.relation, id) )
|
||||
|
||||
# if field.ttype == 'many2many':
|
||||
# if field.ttype == 'reference':
|
||||
|
||||
return _stack
|
||||
|
||||
else:
|
||||
_ctree['error'] = 'Model do not exists'
|
||||
|
||||
return _tree
|
||||
|
||||
def lookup( model, domains ):
|
||||
eprint( "> Lookup: %s %s" % (model,domains) )
|
||||
|
|
Loading…
Reference in New Issue