changeset de8cd44d204b in trytond:4.6
details: https://hg.tryton.org/trytond?cmd=changeset;node=de8cd44d204b
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 d11fbdd6ed4f -r de8cd44d204b trytond/model/fields/selection.py
--- a/trytond/model/fields/selection.py Sat Jan 05 18:28:41 2019 +0100
+++ b/trytond/model/fields/selection.py Sun Dec 30 00:14:27 2018 +0100
@@ -74,12 +74,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]
class TranslatedSelection(object):