[MERGE] orm: port of 5.0 fix for parent_store computation when previous parent is NULL

lp bug: https://launchpad.net/bugs/581137 fixed

bzr revid: odo@openerp.com-20100622155719-a6g6udc6p2s6cp0v
This commit is contained in:
Borja López Soilán (Pexego) 2010-06-22 17:57:19 +02:00 committed by Olivier Dony
parent 8f841dc233
commit 86b55a1b3e
2 changed files with 8 additions and 6 deletions

View File

@ -176,7 +176,8 @@ def handler(signum, _):
logger.notifyChannel('shutdown', netsvc.LOG_INFO,
"Shutdown Server! - %s" % ( SIGNALS[signum], ))
logger.shutdown()
sys.exit(0)
#sys.exit(0)
os._exit(0)
for signum in SIGNALS:
signal.signal(signum, handler)

View File

@ -3173,14 +3173,15 @@ class orm(orm_template):
# The parent_left/right computation may take up to
# 5 seconds. No need to recompute the values if the
# parent is the same. Get the current value of the parent
base_query = 'SELECT id FROM %s WHERE id IN %%s AND %s' % \
(self._table, self._parent_name)
params = (tuple(ids),)
parent_val = vals[self._parent_name]
if parent_val:
cr.execute(base_query + " != %s", params + (parent_val,))
query = "SELECT id FROM %s WHERE id IN %%s AND (%s != %%s OR %s IS NULL)" % \
(self._table, self._parent_name, self._parent_name)
cr.execute(query, (tuple(ids), parent_val))
else:
cr.execute(base_query + " IS NULL", params)
query = "SELECT id FROM %s WHERE id IN %%s AND (%s IS NOT NULL)" % \
(self._table, self._parent_name)
cr.execute(query, (tuple(ids),))
parents_changed = map(operator.itemgetter(0), cr.fetchall())
upd0 = []