summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rw-r--r--bin/osv/orm.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/bin/osv/orm.py b/bin/osv/orm.py
index 20e7089057d..df458553d3b 100644
--- a/bin/osv/orm.py
+++ b/bin/osv/orm.py
@@ -3426,14 +3426,19 @@ class orm(orm_template):
clause, params = '%s=%%s' % (self._parent_name,), (parent_val,)
else:
clause, params = '%s IS NULL' % (self._parent_name,), ()
- cr.execute('SELECT parent_right, id FROM %s WHERE %s ORDER BY %s' % (self._table, clause, order), params)
- parents = cr.fetchall()
for id in parents_changed:
cr.execute('SELECT parent_left, parent_right FROM %s WHERE id=%%s' % (self._table,), (id,))
pleft, pright = cr.fetchone()
distance = pright - pleft + 1
+ # Positions of current siblings, to locate proper insertion point;
+ # this can _not_ be fetched outside the loop, as it needs to be refreshed
+ # after each update, in case several nodes are sequentially inserted one
+ # next to the other (i.e computed incrementally)
+ cr.execute('SELECT parent_right, id FROM %s WHERE %s ORDER BY %s' % (self._table, clause, order), params)
+ parents = cr.fetchall()
+
# Find Position of the element
position = None
for (parent_pright, parent_id) in parents: