Karla,

Il giorno venerdì 29 dicembre 2017 15:06:02 UTC+1, Karla Stenger ha scritto:
> 2017-12-29 7:31 GMT-03:00 Cato Nano <[email protected]>:
> > Hello,
> Hello
> 
> >
> > Could anyone give me a brief, clear example of how to have a calculated 
> > field ?
> >
> > I' m trying to have my first calculated field
> >
> > I have 2 Date fields and I want my calculated field to be the difference in 
> > days between the 2 dates
> >
> > How do I set that ?
> 
> You are looking for fields.Function [1]

Thank you so much for your clarification, I think I understand now

But I'm having a types problem

I have 2 Date fields: startDate and endDate

I want the difference in days

I have this line

return abs((self.endDate - self.startDate).days)

But in the client I get this error

TypeError: unsupported operand type(s) for -: 'NoneType' and 'NoneType'

NoneType ? I was expecting my dates to be datetime.date type !

So I read here (fields of type Date)
http://doc.tryton.org/4.6/trytond/doc/ref/models/fields.html

Also, I see here, that there is an assertion that my date is of type 
datetime.date ( class Date(Field) )
https://hg.tryton.org/trytond/file/tip/trytond/model/fields/date.py

Maybe this is more a Python question than a Tryton one

Please bear with me

-- 
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/770d16cd-31fb-4c7e-8a5f-6f99047b00e6%40googlegroups.com.

Reply via email to