From e364e897511df7e7a21ba7615bb44076bab5e403 Mon Sep 17 00:00:00 2001 From: "Jay (Open ERP)" Date: Wed, 12 May 2010 16:16:15 +0530 Subject: [PATCH] [FIX] orm: ensure the cursor is valid before computing parent_store values bzr revid: jvo@tinyerp.com-20100512104615-wp6v9cpp5jh8py0i --- bin/osv/orm.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bin/osv/orm.py b/bin/osv/orm.py index 00c3f42ec4e..3baa8daa6fc 100644 --- a/bin/osv/orm.py +++ b/bin/osv/orm.py @@ -2451,6 +2451,8 @@ class orm(orm_template): cr.execute("SELECT relname FROM pg_class WHERE relkind in ('r','v') AND relname=%s", (self._table,)) create = not bool(cr.fetchone()) + cr.commit() # start a new transaction + for (key, con, _) in self._sql_constraints: conname = '%s_%s' % (self._table, key) cr.execute("SELECT conname FROM pg_constraint where conname=%s", (conname,)) @@ -2460,6 +2462,7 @@ class orm(orm_template): cr.commit() except: logger.notifyChannel('orm', netsvc.LOG_WARNING, 'unable to add \'%s\' constraint on table %s !\n If you want to have it, you should update the records and execute manually:\nALTER table %s ADD CONSTRAINT %s_%s %s' % (con, self._table, self._table, self._table, key, con,)) + cr.rollback() if create: if hasattr(self, "_sql"): @@ -2470,6 +2473,7 @@ class orm(orm_template): cr.commit() if store_compute: self._parent_store_compute(cr) + cr.commit() return todo_end def __init__(self, cr):