← Back to team overview

openerp-india team mailing list archive

[Bug 1084410] [NEW] [Trunk, 6.1 ] Order by don't work for related fields

 

Public bug reported:

Order by don't work for related fields.

For examples:
1)
class mega_maintenance_order(osv.osv):
    _name = 'mega.maintenance.order'

    _columns = {
        'name': fields.char('Name', size=64, required=True),
        'counter_id': fields.many2one('mega.maintenance.counter', 'Planned Counter', ondelete='cascade'),
        'date_order': fields.related('counter_id', 'date', type='date', string='Planned Date'),
    }

    _order = 'date_order desc'

Will generate an error.

ProgrammingError: column "date_order" does not exist
LINE 1: ..._order".id FROM "mega_maintenance_order" ORDER BY date_order...
                                                                                                                          ^

2)
order_ids = self.pool.get('mega.maintenance.order').search(cr, uid, [], limit=1, order='date_order desc')

Will not sort order by 'date_order'

** Affects: openobject-server
     Importance: Undecided
         Status: New

** Description changed:

  Order by don't work for related fields.
  
  For examples:
- 1) 
+ 1)
  class mega_maintenance_order(osv.osv):
-     _name = 'mega.maintenance.order'
+     _name = 'mega.maintenance.order'
  
- _columns = {
-         'name': fields.char('Name', size=64, required=True),
-         'counter_id': fields.many2one('mega.maintenance.counter', 'Planned Counter', ondelete='cascade'),
-         'date_order': fields.related('counter_id', 'date', type='date', string='Planned Date'),
-     }
+     _columns = {
+         'name': fields.char('Name', size=64, required=True),
+         'counter_id': fields.many2one('mega.maintenance.counter', 'Planned Counter', ondelete='cascade'),
+         'date_order': fields.related('counter_id', 'date', type='date', string='Planned Date'),
+     }
  
- _order = 'date_order desc'
+     _order = 'date_order desc'
  
  Will generate an error.
  
  ProgrammingError: column "date_order" does not exist
  LINE 1: ..._order".id FROM "mega_maintenance_order" ORDER BY date_order...
-                                                                                                                           ^
+                                                                                                                           ^
  
- 2) 
+ 2)
  order_ids = self.pool.get('mega.maintenance.order').search(cr, uid, [], limit=1, order='date_order desc')
  
  Will not sort order by 'date_order'

-- 
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/1084410

Title:
  [Trunk,6.1 ] Order by don't work for related fields

Status in OpenERP Server:
  New

Bug description:
  Order by don't work for related fields.

  For examples:
  1)
  class mega_maintenance_order(osv.osv):
      _name = 'mega.maintenance.order'

      _columns = {
          'name': fields.char('Name', size=64, required=True),
          'counter_id': fields.many2one('mega.maintenance.counter', 'Planned Counter', ondelete='cascade'),
          'date_order': fields.related('counter_id', 'date', type='date', string='Planned Date'),
      }

      _order = 'date_order desc'

  Will generate an error.

  ProgrammingError: column "date_order" does not exist
  LINE 1: ..._order".id FROM "mega_maintenance_order" ORDER BY date_order...
                                                                                                                            ^

  2)
  order_ids = self.pool.get('mega.maintenance.order').search(cr, uid, [], limit=1, order='date_order desc')

  Will not sort order by 'date_order'

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


Follow ups

References