summaryrefslogtreecommitdiff
path: root/openerpcommand/read.py
diff options
context:
space:
mode:
authorAntony Lesuisse <lesuisse@gmail.com>2014-05-29 18:33:04 +0200
committerAntony Lesuisse <lesuisse@gmail.com>2014-05-29 18:33:04 +0200
commitd4624fa826a5e9542782f2c53c8ba2c766d093bc (patch)
treebe214779eb6d1f17157aa48e72fbcbf95405e38b /openerpcommand/read.py
parent045ecc603e67911a5390c812cb6b5b123d9c190e (diff)
[IMP] repository cleanup
- move packaging stuff to setup - remove historical stuff - remove oe, odoo-cmd-fme will be merged with the convered commands - add an odoo.py script to run odo and boostrap it - simplify README - prepare to move documentation to the github wiki
Diffstat (limited to 'openerpcommand/read.py')
-rw-r--r--openerpcommand/read.py61
1 files changed, 0 insertions, 61 deletions
diff --git a/openerpcommand/read.py b/openerpcommand/read.py
deleted file mode 100644
index 61c05117875..00000000000
--- a/openerpcommand/read.py
+++ /dev/null
@@ -1,61 +0,0 @@
-"""
-Read a record.
-"""
-import os
-import sys
-import textwrap
-
-import common
-
-# TODO provide a --rpc flag to use XML-RPC (with a specific username) instead
-# of server-side library.
-def run(args):
- assert args.database
- assert args.model
- import openerp
- config = openerp.tools.config
- config['log_handler'] = [':CRITICAL']
- common.set_addons(args)
- openerp.netsvc.init_logger()
- registry = openerp.modules.registry.RegistryManager.get(
- args.database, update_module=False)
- model = registry[args.model]
- field_names = [args.field] if args.field else []
- if args.short:
- # ignore --field
- field_names = ['name']
- with registry.cursor() as cr:
- xs = model.read(cr, 1, args.id, field_names, {})
-
- if xs:
- print "Records (model `%s`, database `%s`):" % (args.model, args.database)
- x = xs[0]
- if args.short:
- print str(x['id']) + '.', x['name']
- else:
- longest_k = 1
- for k, v in x.items():
- longest_k = len(k) if longest_k < len(k) else longest_k
- for k, v in sorted(x.items()):
- print (k + ':').ljust(longest_k + 2), v
- else:
- print "Record not found."
-
-def add_parser(subparsers):
- parser = subparsers.add_parser('read',
- description='Display a record.')
- parser.add_argument('-d', '--database', metavar='DATABASE',
- **common.required_or_default('DATABASE', 'the database to connect to'))
- common.add_addons_argument(parser)
- parser.add_argument('-m', '--model', metavar='MODEL', required=True,
- help='the model for which a record should be read')
- parser.add_argument('-i', '--id', metavar='RECORDID', required=True,
- help='the record id')
- parser.add_argument('-v', '--verbose', action='store_true',
- help='display more information')
- parser.add_argument('--short', action='store_true',
- help='display less information')
- parser.add_argument('-f', '--field', metavar='FIELD',
- help='display information only for this particular field')
-
- parser.set_defaults(run=run)