Odoo Help

2

5
7 Answers
3
Miku Laitinen Finland
5/14/15, 10:25 AM

Don't use strftime with hard-coded times. It doesn't take different time zones into account. Instead, use this

<filter name="today" string="Today" 
domain="[('date','>=', datetime.datetime.combine(context_today(), datetime.time(0,0,0))),
('date','<=', datetime.datetime.combine(context_today(), datetime.time(23,59,59)))]" />

For example, I'm on UTC+3 now and when I set the min_date of a stock.picking to 2015-05-14 02:00, it's saved to the database as 2015-05-13 23:00. Using strftime in the domain will only work if the min_date is 2015-05-14 03:00 (=2015-05-14 00:00 UTC).

See this commit and this issue.

1 Comment
P.V.Anthony Singapore
4/23/16, 4:47 AM

Thank you for sharing this. It has been very useful for me.

2
Avatar

Anas Taji Jordan

--Anas Taji--
2283
| 7 7 10
Amman, Jordan
--Anas Taji--

Skype: anas.taji-sw

Email: anas.taji@smartway-jo.com

Anas Taji Jordan
5/18/14, 5:57 PM

Try it this way:

<filter string="Today" domain="[('date','&lt;=',time.strftime('%Y-%m-%d 23:59:59')),('date','&gt;=',time.strftime('%Y-%m-%d 00:00:00'))]"/>

1 Comment
walaa Jordan
9/7/14, 4:43 AM
1

You will need to go to menu Settings > Technical > User Interface > User-defined filters

There you will see your saved filters in which date already set as specific date.

You need to make the domain here more generic, i.e, 

['date_payment', '<=', time.strftime('%Y-%m-%d 23:59:59')]

0
Josean Soroa Spain
12/26/17, 1:03 PM

Solution from Miku Laitinen works perfect.

I'm using v10 but it seems it doesn't matter wich version.

Thanks a lot.

0
Antonio Gutierrez Spain
1/20/14, 8:27 AM

if any answers is given. This can be cataloged as bug.

Ask a Question
Tags
Keep Informed
5 follower(s)
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