On 2016-04-01 18:14, Jon Levy wrote:
> 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__
> return inst.__getattr__(self.name)
> 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
I guess it is because the value in the database of the column
'association' is not an id but something that int() can convert (maybe a
float).
Maybe we should change the test that convert to int() by an isinstance
test.
--
Cédric Krier - B2CK SPRL
Email/Jabber: [email protected]
Tel: +32 472 54 46 59
Website: http://www.b2ck.com/
--
You received this message because you are subscribed to the Google Groups
"tryton" group.
To view this discussion on the web visit
https://groups.google.com/d/msgid/tryton/20160402085304.GI13082%40tetsuo.