From 86b55a1b3ebe12b15dcb7854d7d16f6fa4ea0405 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Borja=20L=C3=B3pez=20Soil=C3=A1n=20=28Pexego=29?= <> Date: Tue, 22 Jun 2010 17:57:19 +0200 Subject: [PATCH] [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 --- bin/openerp-server.py | 3 ++- bin/osv/orm.py | 11 ++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/bin/openerp-server.py b/bin/openerp-server.py index 4fbebb84490..0577e76679f 100755 --- a/bin/openerp-server.py +++ b/bin/openerp-server.py @@ -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) diff --git a/bin/osv/orm.py b/bin/osv/orm.py index feb10ab47a4..24df380bdc0 100644 --- a/bin/osv/orm.py +++ b/bin/osv/orm.py @@ -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 = []