Added save command

This commit is contained in:
DiG 2022-01-17 16:01:51 +01:00
parent c5fd18e0cc
commit 38d9f0ab7a
1 changed files with 13 additions and 10 deletions

View File

@ -25,13 +25,14 @@ FOLDER = '/home/dig/odoo-export/datas'
PARAMS = [] PARAMS = []
OPTS = {} OPTS = {}
for param in sys.argv[1:]: for param in sys.argv[1:]:
if param[0] == '-': # if param[0] == '-':
kv = param[1:].split( '=' ) # kv = param[1:].split( '=' )
if len(kv) == 1: # if len(kv) == 1:
OPTS[kv[0]] = False # OPTS[kv[0]] = False
else: # else:
OPTS[kv[0]] = kv[1] # OPTS[kv[0]] = kv[1]
elif param[0] == '+': # elif
if param[0] == '+':
kv = param[1:].split( '=' ) kv = param[1:].split( '=' )
if len(kv) == 1: if len(kv) == 1:
OPTS[kv[0]] = True OPTS[kv[0]] = True
@ -348,7 +349,7 @@ def flatten_stack( data ):
if type(obj) == list: if type(obj) == list:
# eprint( 'is a list') # eprint( 'is a list')
for item in obj: for item in obj:
print( 'item: ', item, type(item)) # eprint( 'item: ', item, type(item))
if type(item) in (str,unicode): if type(item) in (str,unicode):
# eprint( 'sub item is a str') # eprint( 'sub item is a str')
flat.append( item ) flat.append( item )
@ -471,7 +472,9 @@ def export_json( model, domains ):
def save( model, domains ): def save( model, domains ):
return 'save' force = OPTS['force'] if 'force' in OPTS else False
models = lookup( model, domains )
return models
# AUTO EXEC # AUTO EXEC
@ -533,7 +536,7 @@ if MODEL in odoo.env:
export_json( MODEL, args2domains(PARAMS[2:]) ) export_json( MODEL, args2domains(PARAMS[2:]) )
if METHOD == 'save': if METHOD == 'save':
save( MODEL, args2domains(PARAMS[2:]) ) jlog( save( MODEL, args2domains(PARAMS[2:]) ) )
elif MODEL == 'db': elif MODEL == 'db':
if METHOD == 'list': if METHOD == 'list':