changeset b486cb9174cf in trytond:4.8
details: https://hg.tryton.org/trytond?cmd=changeset;node=b486cb9174cf
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 aa5e91ab1845 -r b486cb9174cf trytond/model/fields/selection.py
--- a/trytond/model/fields/selection.py Sat Jan 05 18:27:08 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):

Reply via email to