Il giorno martedì 13 febbraio 2018 12:20:10 UTC+1, Cato Nano ha scritto:
> Il giorno lunedì 12 febbraio 2018 10:29:56 UTC+1, Cato Nano ha scritto:
> > 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
> 
> 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


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


-- 
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/b6ee3638-4c30-42a0-86d5-de710f548cc6%40googlegroups.com.

Reply via email to