summaryrefslogtreecommitdiff
path: root/openerpcommand/read.py
diff options
context:
space:
mode:
authorRaphael Collet <rco@openerp.com>2014-04-08 14:51:22 +0200
committerRaphael Collet <rco@openerp.com>2014-04-08 14:51:22 +0200
commit6bc60505f4e25d5ce7181f30d33692a8e7d08fe0 (patch)
treefec08c9fd2716b38973bec28db672e05ec6fdc91 /openerpcommand/read.py
parentb49f536baff6fab13884f4b2b6fdee1cb407f128 (diff)
[IMP] registry: add method get_cursor() to simply retrieve a new cursor, and refactor code to use it
bzr revid: rco@openerp.com-20140408125122-ki0zmin3m21k2itd
Diffstat (limited to 'openerpcommand/read.py')
-rw-r--r--openerpcommand/read.py5
1 files changed, 1 insertions, 4 deletions
diff --git a/openerpcommand/read.py b/openerpcommand/read.py
index 5b68fb26ef0..61c05117875 100644
--- a/openerpcommand/read.py
+++ b/openerpcommand/read.py
@@ -20,15 +20,12 @@ def run(args):
registry = openerp.modules.registry.RegistryManager.get(
args.database, update_module=False)
model = registry[args.model]
- cr = registry.db.cursor() # TODO context manager
field_names = [args.field] if args.field else []
if args.short:
# ignore --field
field_names = ['name']
- try:
+ with registry.cursor() as cr:
xs = model.read(cr, 1, args.id, field_names, {})
- finally:
- cr.close()
if xs:
print "Records (model `%s`, database `%s`):" % (args.model, args.database)