Skip to Content
Menu
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
Related Posts Replies Views Activity
2
Mar 16
14864
1
Jan 20
9455
0
Mar 15
5627
4
Oct 24
9455
2
Jan 23
12102