not callable

29 views
Skip to first unread message

Cato Nano

unread,
Feb 12, 2018, 4:29:56 AM2/12/18
to tryton
I am creating some new calculated fields, running tests along the way

The last one of such fields is giving me troubles

This is the result of running the tests


.............F
======================================================================
FAIL: /home/catonano/tributi/build/lib/trytond/modules/tributi/tests/scenario_affissioni.rst
Doctest: scenario_affissioni.rst
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib64/python3.6/doctest.py", line 2199, in runTest
raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for scenario_affissioni.rst
File "/home/catonano/tributi/build/lib/trytond/modules/tributi/tests/scenario_affissioni.rst", line 0

----------------------------------------------------------------------
File "/home/catonano/tributi/build/lib/trytond/modules/tributi/tests/scenario_affissioni.rst", line 77, in scenario_affissioni.rst
Failed example:
bolletta.lines.append(unaAffissione)
Exception raised:
Traceback (most recent call last):
File "/usr/lib64/python3.6/doctest.py", line 1330, in __run
compileflags, 1), test.globs)
File "<doctest scenario_affissioni.rst[52]>", line 1, in <module>
bolletta.lines.append(unaAffissione)
File "/home/catonano/tributi/env/lib/python3.6/site-packages/proteus/__init__.py", line 553, in append
self.__check([record])
File "/home/catonano/tributi/env/lib/python3.6/site-packages/proteus/__init__.py", line 548, in __check
setattr(record, self.parent_name, self.parent)
File "/home/catonano/tributi/env/lib/python3.6/site-packages/proteus/__init__.py", line 260, in __set__
super(Many2OneDescriptor, self).__set__(instance, value)
File "/home/catonano/tributi/env/lib/python3.6/site-packages/proteus/__init__.py", line 129, in __set__
instance._on_change([self.name])
File "/home/catonano/tributi/env/lib/python3.6/site-packages/proteus/__init__.py", line 1076, in _on_change
context)
File "/home/catonano/tributi/env/lib/python3.6/site-packages/proteus/config.py", line 164, in __call__
raise TypeError('%s is not callable' % self._name)
TypeError: on_change_with_risultatoRigo is not callable


----------------------------------------------------------------------
Ran 14 tests in 16.610s

FAILED (failures=1)

why is it not callable ?

It's no different than many other methods and they are all callable

It' s here
https://gitlab.com/humanitiesNerd/tributi/blob/master/affissione.py#L165

Thanks in advance

Cato Nano

unread,
Feb 13, 2018, 6:20:10 AM2/13/18
to tryton
even from within Proteus I can' t find the attribute.

I don't understand, it's no different than at least other 3 fields;

Those work. This one doesn't

For now I gave up in making it depend on another calculated field and I' m doing the same calculations again

But the fact that I don' t understand the issue makes me uncomfortable

Cato Nano

unread,
Mar 14, 2018, 4:53:07 AM3/14/18
to tryton
I found the problem

Here is an example
https://gitlab.com/humanitiesNerd/tributi/blob/master/affissione.py#L176

if you don' t mind click on the link, here's the code

if self.formato:
if int(self.formato) >= 16:
somma = somma * 2
if 8 <= int(self.formato) <= 12:
somma = somma * 1.5

In this example, the introductory

if self.formato:
...

is necessary

in fact, WITHOUT that introductory if, like this

if int(self.formato) >= 16:
somma = somma * 2
if 8 <= int(self.formato) <= 12:
somma = somma * 1.5

self. formato would turn out to be NoneType


This discovery allowed me to continue and finish this stage of the project

Admittedly I had to do some research about python decorators, in order to understand this

Probably more research will be necessary, anyway

I know I bothered you, I apologize


Reply all
Reply to author
Forward
0 new messages