Odoo Help

0

Filtering on hours, minutes or seconds intervals

By
Graham Vickrage
on 4/16/18, 8:35 AM 173 views

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. 

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 4/16/18, 8:35 AM
Seen: 173 times
Last updated: 4/16/18, 8:56 AM