Added module renderers json tsv csv xml

This commit is contained in:
DiG 2022-01-16 18:45:33 +01:00
parent 432a93e2ee
commit b689d71c22
2 changed files with 6 additions and 6 deletions

View File

@ -237,8 +237,9 @@ def search( model, domains ):
def fields( model, domains ):
Model = odoo.env['ir.model.fields']
ids = Model.search([( 'model_id.model', '=', model )])
render( model, Model.browse(ids) )
domains = [( 'model_id.model', '=', model )].append( domains )
ids = Model.search( domains )
render( OPTS, model, Model.browse(ids) )
stack = []
current_exports = []
@ -443,7 +444,7 @@ if MODEL in odoo.env:
if METHOD == 'search':
# render_tsv( odoo.env[MODEL].browse( odoo.env[MODEL].search( args2domains(PARAMS[2:]) ) ) )
ids = search( MODEL, args2domains(PARAMS[2:]) )
render( MODEL, Model.browse(ids) )
render( OPTS, MODEL, Model.browse(ids) )
#ids = Model.search( args2domains(PARAMS[2:]) )
#print( 'id', 'name', sep='\t' )
#for inst in Model.browse( ids ):
@ -474,7 +475,7 @@ if MODEL in odoo.env:
if METHOD == 'fields':
Model = odoo.env['ir.model.fields']
ids = Model.search([( 'model_id.model', '=', MODEL )])
render( MODEL, Model.browse(ids) )
render( OPTS, MODEL, Model.browse(ids) )
#for inst in Field.browse( ids ):
# render_tsv( 'ir.model.fields', inst )

View File

@ -34,8 +34,7 @@ def render_json( model, list ):
jlog( list )
#def render_json( model, obj ):
def render( model, list ): # +format=json,xml,csv +json +tsv
print( 'OPTS dans module : ', OPTS )
def render( opts, model, list ): # +format=json,xml,csv +json +tsv
if opts.json or ( opts.format and 'json' in opts.format ):
render_json( model, list )
if opts.tsv or ( opts.format and 'tsv' in opts.format ):