← Back to team overview

openerp-india team mailing list archive

[Bug 989641] Re: column's priority attr has no effect in osv_memory

 

Hi ,

I have watched the video you attached. And as you say you are using the
code on trunk (i saw 6.2 in the video). I also checkout the code on
trunk. Found that even 6.1 has a lot of changes in osv/orm.py
(osv_memory reimplement totally).

So i think this would be an issue only on 6.0 ? Now i am going to
checkout the latest code of 6.0 branch to see what happen.

-- 
You received this bug notification because you are a member of OpenERP
Indian Team, which is subscribed to OpenERP Server.
https://bugs.launchpad.net/bugs/989641

Title:
  column's priority attr has no effect in osv_memory

Status in OpenERP Server:
  Incomplete

Bug description:
  I have a model that contains several function fields, they need to
  compute in some order. If in osv.osv i can use the priority attribute
  to force the compute order. But if it is a osv_memory, it seems that
  they have no effect at all.

  
  server:  debian 2.6.32-5-686
  oerp server installed by: openerp-server-6.0.2-0_all.deb

  
  example code:
  ================================= 
  import netsvc
  from osv import osv, fields

  class MyObj(osv.osv):

      def _get_col(self, cr, uid, ids, field_name, arg, context=None):
          return dict(((id, '') for id in ids))

      def _set_col(self, cr, uid, id, field_name, field_val, arg, context=None):
          netsvc.Logger().notifyChannel('_set_col', netsvc.LOG_ERROR,
                  'setting %s to %s' % (field_name, field_val))
          return True

      _name = 'my.obj'
      _columns = {
          'col1': fields.function(_get_col, fnct_inv=_set_col, type='char',
              size=32,
              method=True,
              priority=10,
              string='Col1'),
          'col2': fields.function(_get_col, fnct_inv=_set_col, type='char',
              size=32,
              method=True,
              priority=11,
              string='Col2'),
      }

  MyObj()
  =================================

  if running
      pool.get('my.obj').write(cr, uid, ids, {'col1': '1', 'col2': '2'})

  the log shows

  [2012-04-27 07:14:54,471][openerp_db] ERROR:_set_col:setting col1 to 1
  [2012-04-27 07:14:54,473][openerp_db] ERROR:_set_col:setting col2 to 2

  but if it changes to 
    class MyObj(osv.osv_memory):

  the log will show

  [2012-04-27 07:16:46,545][openerp_db] ERROR:_set_col:setting col2 to 2
  [2012-04-27 07:16:46,545][openerp_db] ERROR:_set_col:setting col1 to 1

  
  After reading into the source code, i think this is because the 'write' method of 'orm_memory' lack a line as in 'orm':
    
    upd_todo.sort(lambda x, y: self._columns[x].priority-self._columns[y].priority)

  is it a bug?

To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-server/+bug/989641/+subscriptions


References