From 653d6c3e778970a842e3beae5a9ff5ad6d30be19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 26 Dec 2008 15:25:49 +0100 Subject: [PATCH] Fix order on selection field to order with selection values --- trytond/osv/orm.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/trytond/osv/orm.py b/trytond/osv/orm.py index 8cfd8b1254..b6c98f2d16 100644 --- a/trytond/osv/orm.py +++ b/trytond/osv/orm.py @@ -2947,6 +2947,17 @@ class ORM(object): + table_name + '.' + field_name + ') ' + otype) return order_by, tables, tables_args + if field_name in self._columns \ + and self._columns[field_name]._type == 'selection': + selections = self.fields_get(cursor, user, [field_name], + context=context)[field_name]['selection'] + order = 'CASE ' + table_name + '.' + field_name + for selection in selections: + order += ' WHEN \'%s\' THEN \'%s\'' % selection + order += ' ELSE ' + table_name + '.' + field_name + ' END' + order_by.append(order + ' ' + otype) + return order_by, tables, tables_args + if field_name: if '%(table)s' in field_name or '%(order)s' in field_name: order_by.append(field_name % {