changeset f4fd7ea1d67a in trytond:4.4
details: https://hg.tryton.org/trytond?cmd=changeset;node=f4fd7ea1d67a
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 5173f62349b6 -r f4fd7ea1d67a trytond/model/fields/selection.py
--- a/trytond/model/fields/selection.py Sat Jan 05 18:29:37 2019 +0100
+++ b/trytond/model/fields/selection.py Sun Dec 30 00:14:27 2018 +0100
@@ -63,12 +63,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"

Reply via email to