Discussion:
[tryton] new error
Cato Nano
2018-01-22 04:11:46 UTC
Permalink
In testing my module for the first time, this error is reported

----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/catonano/tributi/env/lib/python3.6/site-packages/trytond/tests/test_tryton.py", line 198, in wrapper
result = func(*args, **kwargs)
File "/home/catonano/tributi/env/lib/python3.6/site-packages/trytond/tests/test_tryton.py", line 361, in test_field_methods
getattr(record, attr)()
File "/home/catonano/tributi/env/lib/python3.6/site-packages/trytond/model/fields/field.py", line 106, in wrapper
return func(self, *args, **kwargs)
File "/home/catonano/tributi/build/lib/trytond/modules/tributi/affissione.py", line 38, in on_change_with_fattoreGiorni
ng = abs((self.on_change_with_bollettaDataFine() - self.on_change_with_bollettaDataInizio()).days)
TypeError: unsupported operand type(s) for -: 'NoneType' and 'NoneType'

----------------------------------------------------------------------


but when I run it in the GUI, fattoreGiorni DOES WORK

I swear !

You can see a picture here
https://imgur.com/a/kUUjs
--
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/c30a9b84-9ec4-443d-9c2b-66a780020a81%40googlegroups.com.
Sergi Almacellas Abellana
2018-01-22 08:32:35 UTC
Permalink
Post by Cato Nano
In testing my module for the first time, this error is reported
----------------------------------------------------------------------
File "/home/catonano/tributi/env/lib/python3.6/site-packages/trytond/tests/test_tryton.py", line 198, in wrapper
result = func(*args, **kwargs)
File "/home/catonano/tributi/env/lib/python3.6/site-packages/trytond/tests/test_tryton.py", line 361, in test_field_methods
getattr(record, attr)()
File "/home/catonano/tributi/env/lib/python3.6/site-packages/trytond/model/fields/field.py", line 106, in wrapper
return func(self, *args, **kwargs)
File "/home/catonano/tributi/build/lib/trytond/modules/tributi/affissione.py", line 38, in on_change_with_fattoreGiorni
ng = abs((self.on_change_with_bollettaDataFine() - self.on_change_with_bollettaDataInizio()).days)
TypeError: unsupported operand type(s) for -: 'NoneType' and 'NoneType'
----------------------------------------------------------------------
The problem is that both on_change functions return a None value and
python does not know how too substract None from None. That's because
the test suite call all on_change functions with an empty object to
ensure that they correctly work when there is no value on the form.

You should take in account None values on your function.
Post by Cato Nano
but when I run it in the GUI, fattoreGiorni DOES WORK
I swear !
You can see a picture here
https://imgur.com/a/kUUjs
--
Sergi Almacellas Abellana
www.koolpi.com
Twitter: @pokoli_srk
--
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/2709c9d9-0dbc-7403-1881-3373f7782c93%40koolpi.com.
Cato Nano
2018-01-22 18:03:15 UTC
Permalink
Post by Sergi Almacellas Abellana
Post by Cato Nano
In testing my module for the first time, this error is reported
----------------------------------------------------------------------
File "/home/catonano/tributi/env/lib/python3.6/site-packages/trytond/tests/test_tryton.py", line 198, in wrapper
result = func(*args, **kwargs)
File "/home/catonano/tributi/env/lib/python3.6/site-packages/trytond/tests/test_tryton.py", line 361, in test_field_methods
getattr(record, attr)()
File "/home/catonano/tributi/env/lib/python3.6/site-packages/trytond/model/fields/field.py", line 106, in wrapper
return func(self, *args, **kwargs)
File "/home/catonano/tributi/build/lib/trytond/modules/tributi/affissione.py", line 38, in on_change_with_fattoreGiorni
ng = abs((self.on_change_with_bollettaDataFine() - self.on_change_with_bollettaDataInizio()).days)
TypeError: unsupported operand type(s) for -: 'NoneType' and 'NoneType'
----------------------------------------------------------------------
The problem is that both on_change functions return a None value and
python does not know how too substract None from None. That's because
the test suite call all on_change functions with an empty object to
ensure that they correctly work when there is no value on the form.
You should take in account None values on your function.
Post by Cato Nano
but when I run it in the GUI, fattoreGiorni DOES WORK
I swear !
You can see a picture here
https://imgur.com/a/kUUjs
--
Sergi Almacellas Abellana
www.koolpi.com
Thank you Sergi

I managed to give my date fiuelds default values AND make my methods return a date _anyway_.

That allowed the tests to pass
--
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/aad1211a-f04c-4614-810e-0f55f0e28df5%40googlegroups.com.
Loading...