Merge lp:~borjals/openobject-server/5.0-bugfix-581137 into lp:openobject-server/5.0

Proposed by Borja López Soilán (NeoPolus)
Status: Merged
Merged at revision: 2074
Proposed branch: lp:~borjals/openobject-server/5.0-bugfix-581137
Merge into: lp:openobject-server/5.0
Diff against target: 24 lines (+6/-5)
1 file modified
bin/osv/orm.py (+6/-5)
To merge this branch: bzr merge lp:~borjals/openobject-server/5.0-bugfix-581137
Reviewer Review Type Date Requested Status
Olivier Dony (Odoo) Pending
Review via email: mp+25540@code.launchpad.net

Commit message

Fix the parent_store computation

Description of the change

Fix the parent_store computation when parent_id is changed from NULL to anything else, or from any parent_id back to NULL.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/osv/orm.py'
2--- bin/osv/orm.py 2010-05-18 13:57:53 +0000
3+++ bin/osv/orm.py 2010-05-18 17:39:29 +0000
4@@ -2555,14 +2555,15 @@
5 # The parent_left/right computation may take up to
6 # 5 seconds. No need to recompute the values if the
7 # parent is the same. Get the current value of the parent
8- base_query = 'SELECT id FROM %s WHERE id IN %%s AND %s' % \
9- (self._table, self._parent_name)
10- params = (tuple(ids),)
11 parent_val = vals[self._parent_name]
12 if parent_val:
13- cr.execute(base_query + " != %s", params + (parent_val,))
14+ query = "SELECT id FROM %s WHERE id IN %%s AND (%s != %%s OR %s IS NULL)" % \
15+ (self._table, self._parent_name, self._parent_name)
16+ cr.execute(query, (tuple(ids), parent_val))
17 else:
18- cr.execute(base_query + " IS NULL", params)
19+ query = "SELECT id FROM %s WHERE id IN %%s AND (%s IS NOT NULL)" % \
20+ (self._table, self._parent_name)
21+ cr.execute(query, (tuple(ids),))
22 parents_changed = map(operator.itemgetter(0), cr.fetchall())
23
24 upd0 = []