This question has been flagged

Using the ir.filters model on Odoo V8 i'm trying to get all records within the previous hour. The following does not work. 'date' is a datetime field.

['date', '>', ( (context_today() - datetime.timedelta(hours=1)).strftime('%Y-%m-%d %H:%m:%S') ) ]

If I remove the time element %H:%m:%S then there are no errors but truncates to midnight so returns all records today which I would expect but not what I want. I've read that you may have to use datetime.combine but am unable to get this working without hardcoding the hours / minutes / seconds.

Can anyone give me an example of how to achieve what should be a simple filter option. 

Avatar
Discard