Use callable instead of instance of collections.Callable
issue7666 review50571002
This commit is contained in:
1 parent
3c80cfd8c4
commit
81375e0d45
2 files changed
+2
-4
No files matched your search
@@ -2,7 +2,6 @@
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
|
||||
import copy
|
||||
import collections
|
||||
from functools import total_ordering
|
||||
|
||||
from trytond.model import fields
|
||||
@@ -77,7 +76,7 @@ class Model(WarningErrorMixin, URLMixin, PoolBase, metaclass=ModelMeta):
|
||||
fields_names = list(cls._fields.keys())
|
||||
for field_name in fields_names:
|
||||
default_method = getattr(cls, 'default_%s' % field_name, False)
|
||||
if isinstance(default_method, collections.Callable):
|
||||
if callable(default_method):
|
||||
cls._defaults[field_name] = default_method
|
||||
|
||||
for k in cls._defaults:
|
||||
|
||||
@@ -170,8 +170,7 @@ class ModelView(Model):
|
||||
meth_done = set()
|
||||
while meth_names:
|
||||
meth_name = meth_names.pop()
|
||||
assert isinstance(
|
||||
getattr(cls, meth_name), collections.Callable), \
|
||||
assert callable(getattr(cls, meth_name)), \
|
||||
"%s.%s not callable" % (cls, meth_name)
|
||||
setattr(field, attribute,
|
||||
getattr(field, attribute) | methods['depends'][meth_name])
|
||||
|
||||
Reference in new issue
Block a user