I am working to migrate my 3.0 installation to 3.4, but I've run into problems with
function fields. I can't find any relevant changes in the documentation or
notes in the wiki.
Two fields, so far, crash in tests that passed in 3.0.
(1)
Behavior:
Given an instance of MyClass, attempts to access
the_instance.current result in: "RuntimeError: maximum recursion depth exceeded"
Code (simplified):
class MyClass(ModelSQL, ModelView):
association = fields.Many2One('my_module.association', 'Association',
required=True, select=True, ondelete='CASCADE”
)
current = fields.Function(fields.Boolean('Current'), 'get_current')
def get_current(self, name):
"Get current"
return self.association.is_current
# same error also results when replacing the code with
# self.association
# return True
# Ie, the error is simply from accessing the Many2One field
# of the instance.
(2)
Tests that attempt to access this function field report the following
traceback:
Traceback (most recent call last):
File ..., line 2432, in test0130
self.assertEqual(log1.calculable_dh_chain_end, log3)
File "/usr/local/lib/python2.7/dist-packages/trytond/model/fields/field.py",
line 213, in __get__
File "/usr/local/lib/python2.7/dist-packages/trytond/model/modelstorage.py",
line 1332, in __getattr__
fvalue = instantiate(field, data[fname], data)
File "/usr/local/lib/python2.7/dist-packages/trytond/model/modelstorage.py",
line 1303, in instantiate
return Model(value, _ids=ids, _local_cache=local_cache)
File "/usr/local/lib/python2.7/dist-packages/trytond/model/modelstorage.py",
line 1157, in __init__
assert id in _ids
AssertionError
However, it works fine when directly call the getter of the instance. Ie:
an_instance.get_calculable_dh_chain_end(None) # the function doesn't use name
This returns as expected (in the case of the test, log3).
All advice and suggestions are welcome. Thank you in advance for your attention!