mirror of
https://github.com/NaN-tic/trytond-patches.git
synced 2023-12-14 06:03:03 +01:00
36 lines
1.8 KiB
Diff
36 lines
1.8 KiB
Diff
diff --git a/trytond/model/modelstorage.py b/trytond/model/modelstorage.py
|
|
index 32d6a531..e74ff841 100644
|
|
--- a/trytond/trytond/model/modelstorage.py
|
|
+++ b/trytond/trytond/model/modelstorage.py
|
|
@@ -1084,6 +1084,15 @@ class ModelStorage(Model):
|
|
if hasattr(field, 'selection') and field.selection:
|
|
if isinstance(field.selection, (tuple, list)):
|
|
test = set(dict(field.selection).keys())
|
|
+ instance_sel_func = False
|
|
+ else:
|
|
+ sel_func = getattr(cls, field.selection)
|
|
+ instance_sel_func = is_instance_method(cls,
|
|
+ field.selection)
|
|
+ if not instance_sel_func:
|
|
+ test = sel_func()
|
|
+ test = set(dict(test))
|
|
+
|
|
for record in records:
|
|
value = getattr(record, field_name)
|
|
if field._type == 'reference':
|
|
@@ -1091,12 +1100,8 @@ class ModelStorage(Model):
|
|
value = value.__class__.__name__
|
|
elif value:
|
|
value, _ = value.split(',')
|
|
- if not isinstance(field.selection, (tuple, list)):
|
|
- sel_func = getattr(cls, field.selection)
|
|
- if not is_instance_method(cls, field.selection):
|
|
- test = sel_func()
|
|
- else:
|
|
- test = sel_func(record)
|
|
+ if instance_sel_func:
|
|
+ test = sel_func(record)
|
|
test = set(dict(test))
|
|
# None and '' are equivalent
|
|
if '' in test or None in test:
|