~cedric-lebrouster/openobject-server/7.0-bug-1253052-parent-order

« back to all changes in this revision

Viewing changes to openerp/osv/orm.py

  • Committer: Cedric Le Brouster
  • Date: 2014-06-13 10:03:56 UTC
  • Revision ID: cedric.lebrouster@kerbois.com-20140613100356-yay6rhy0o7uhx1ve
[FIX] orm: fix miscalculation of _parent_left and _parent_right in create() method for some special case.
(i.e. when new object parent's _parent_left value is 0)

Show diffs side-by-side

added added

removed removed

Lines of Context:
4482
4482
                    pleft_old = pleft
4483
4483
                if not pleft_old and parent:
4484
4484
                    cr.execute('select parent_left from '+self._table+' where id=%s', (parent,))
4485
 
                    pleft_old = cr.fetchone()[0]
4486
 
                pleft = pleft_old or -1
 
4485
                    pleft = cr.fetchone()[0]
 
4486
                else:
 
4487
                    pleft = pleft_old or -1
4487
4488
                cr.execute('update '+self._table+' set parent_left=parent_left+2 where parent_left>%s', (pleft,))
4488
4489
                cr.execute('update '+self._table+' set parent_right=parent_right+2 where parent_right>%s', (pleft,))
4489
4490
                cr.execute('update '+self._table+' set parent_left=%s,parent_right=%s where id=%s', (pleft+1, pleft+2, id_new))