diff options
| author | Antony Lesuisse <lesuisse@gmail.com> | 2014-05-29 18:33:04 +0200 |
|---|---|---|
| committer | Antony Lesuisse <lesuisse@gmail.com> | 2014-05-29 18:33:04 +0200 |
| commit | d4624fa826a5e9542782f2c53c8ba2c766d093bc (patch) | |
| tree | be214779eb6d1f17157aa48e72fbcbf95405e38b /openerpcommand/model.py | |
| parent | 045ecc603e67911a5390c812cb6b5b123d9c190e (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/model.py')
| -rw-r--r-- | openerpcommand/model.py | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/openerpcommand/model.py b/openerpcommand/model.py deleted file mode 100644 index ccd3ae78718..00000000000 --- a/openerpcommand/model.py +++ /dev/null @@ -1,61 +0,0 @@ -""" -Display information about a given model. -""" -import os -import sys -import textwrap - -def run(args): - assert args.database - assert args.model - import openerp - openerp.tools.config['log_level'] = 100 - openerp.netsvc.init_logger() - registry = openerp.modules.registry.RegistryManager.get( - args.database, update_module=False) - model = registry[args.model] - longest_k = 1 - longest_string = 1 - columns = model._columns - - if args.field and args.field not in columns: - print "No such field." - sys.exit(1) - - if args.field: - columns = { args.field: columns[args.field] } - else: - print "Fields (model `%s`, database `%s`):" % (args.model, args.database) - - for k, v in columns.items(): - longest_k = len(k) if longest_k < len(k) else longest_k - longest_string = len(v.string) \ - if longest_string < len(v.string) else longest_string - for k, v in sorted(columns.items()): - attr = [] - if v.required: - attr.append("Required") - if v.readonly: - attr.append("Read-only") - attr = '/'.join(attr) - attr = '(' + attr + ')' if attr else attr - if args.verbose: - print v.string, '-- ' + k + ', ' + v._type, attr - else: - print k.ljust(longest_k + 2), v._type, attr - if args.verbose and v.help: - print textwrap.fill(v.help, initial_indent=' ', subsequent_indent=' ') - -def add_parser(subparsers): - parser = subparsers.add_parser('model', - description='Display information about a given model for an existing database.') - parser.add_argument('-d', '--database', metavar='DATABASE', required=True, - help='the database to connect to') - parser.add_argument('-m', '--model', metavar='MODEL', required=True, - help='the model for which information should be displayed') - parser.add_argument('-v', '--verbose', action='store_true', - help='display more information') - parser.add_argument('-f', '--field', metavar='FIELD', - help='display information only for this particular field') - - parser.set_defaults(run=run) |
