[FIX] orm : Miscalculation of parent_left/parent_right corrected.
authorAnup (OpenERP) <ach@openerp.com>
Fri, 4 Feb 2011 09:32:33 +0000 (15:02 +0530)
committerAnup (OpenERP) <ach@openerp.com>
Fri, 4 Feb 2011 09:32:33 +0000 (15:02 +0530)
lp bug: https://launchpad.net/bugs/708603 fixed

bzr revid: ach@openerp.com-20110204093233-hg98eemjg6awz3g2

bin/osv/orm.py

index 0554fe8..cca43e1 100644 (file)
@@ -2712,14 +2712,15 @@ 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
-
+                                                
+                    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: