changeset b4e161c4e220 in trytond:4.2
details: https://hg.tryton.org/trytond?cmd=changeset;node=b4e161c4e220
description:
Order selection field with instance method on column
issue7934
review66491002
(grafted from 8f0c905a29740daae6516a209b3d5d47a82e3077)
diffstat:
trytond/model/fields/selection.py | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diffs (24 lines):
diff -r 4f91f2928df3 -r b4e161c4e220 trytond/model/fields/selection.py
--- a/trytond/model/fields/selection.py Sat Jan 05 18:30:21 2019 +0100
+++ b/trytond/model/fields/selection.py Sun Dec 30 00:14:27 2018 +0100
@@ -59,12 +59,18 @@
table, _ = tables[None]
selections = Model.fields_get([name])[name]['selection']
if not isinstance(selections, (tuple, list)):
- selections = getattr(Model, selections)()
+ if not is_instance_method(Model, selections):
+ selections = getattr(Model, selections)()
+ else:
+ selections = []
column = self.sql_column(table)
whens = []
for key, value in selections:
whens.append((column == key, value))
- return [Case(*whens, else_=column)]
+ if whens:
+ return [Case(*whens, else_=column)]
+ else:
+ return [column]
def translated(self, name=None):
"Return a descriptor for the translated value of the field"