Added config folder with TSV columns for each model

This commit is contained in:
DiG 2022-02-06 02:43:41 +01:00
parent 28e8930584
commit 609c495e2c
3 changed files with 7 additions and 7 deletions

View File

@ -4,7 +4,7 @@ import os
APPDIR = os.path.dirname( os.path.realpath(__file__) ) APPDIR = os.path.dirname( os.path.realpath(__file__) )
DATADIR = '%s/datas' % APPDIR DATADIR = '%s/datas' % APPDIR
CONFDIR = '%s/config' % APPDIR CONFDIR = '%s/config' % APPDIR
FOLDER = DATADIR # FOLDER = DATADIR
MODEL_IGNORE = [] MODEL_IGNORE = []
with open(".modelignore", "r") as file: with open(".modelignore", "r") as file:

View File

@ -90,7 +90,7 @@ def get_schema( name ):
#jlog( fields ) #jlog( fields )
obj['field_id'] = fields obj['field_id'] = fields
jlog( transform_model(obj) ) jlog( transform_model(obj) )
eprint( "%s/schemas/%s.json" % ( FOLDER, model.model ) ) eprint( "%s/schemas/%s.json" % ( DATADIR, model.model ) )
def transform_model( obj ): def transform_model( obj ):
return { "name": obj['model'], "modules": obj['modules'], 'fields': [ {} for field in obj['field_id'] ] } return { "name": obj['model'], "modules": obj['modules'], 'fields': [ {} for field in obj['field_id'] ] }
@ -358,12 +358,12 @@ def export_json( model, domains ):
return return
Model = odoo.env[model] Model = odoo.env[model]
ids = Model.search( domains ) ids = Model.search( domains )
ensure_dir( "%s/%s" % (FOLDER, model) ) ensure_dir( "%s/%s" % (DATADIR, model) )
rfields = rel_fields( model ) rfields = rel_fields( model )
eprint( rfields ) eprint( rfields )
for inst in Model.browse( ids ): for inst in Model.browse( ids ):
data = inst.read()[0] data = inst.read()[0]
filename = "%s/%s/%s.json" % ( FOLDER, model, inst.id ) filename = "%s/%s/%s.json" % ( DATADIR, model, inst.id )
if filename in current_exports: if filename in current_exports:
continue continue
@ -395,7 +395,7 @@ def export_json( model, domains ):
if field.ttype == 'one2many': if field.ttype == 'one2many':
for id in data[field.name]: for id in data[field.name]:
_filename = "%s/%s/%s.json" % ( FOLDER, field.relation, id ) _filename = "%s/%s/%s.json" % ( DATADIR, field.relation, id )
print( field.ttype, field.relation, id, _filename ) print( field.ttype, field.relation, id, _filename )
if not os.path.exists( _filename ): if not os.path.exists( _filename ):
export_json( field.relation, [('id','=',id)] ) export_json( field.relation, [('id','=',id)] )

View File

@ -47,10 +47,10 @@ def args2domains( list ):
def file_path( muid, format ): def file_path( muid, format ):
return "%s/%s.%s" % ( FOLDER, muid, format ) return "%s/%s.%s" % ( DATADIR, muid, format )
def json_path( model, id ): def json_path( model, id ):
return "%s/%s.json" % ( FOLDER, Muid(model, id) ) return "%s/%s.json" % ( DATADIR, Muid(model, id) )
def Muid( model, id ): def Muid( model, id ):
return "%s/%s" % ( model, id ) return "%s/%s" % ( model, id )