[FIX] orm: ensure the cursor is valid before computing parent_store values
bzr revid: jvo@tinyerp.com-20100512104615-wp6v9cpp5jh8py0i
This commit is contained in:
parent
db035455a3
commit
e364e89751
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue