Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
I have a filter name today with the next value:
<filter string="Today" domain="[('date','>=',((context_today())).strftime('%%Y-%%m-%%d 00:00:00')), ('date', '<=',((context_today())).strftime('%%Y-%%m-%%d 23:59:59'))]"/>
The date field is datetime and the filter work good. The filter return only values from today.
If i save the filter as default filter, openerp save the actual date and the filter not work tomorrow or other day because the date is saved instead of context_today().
Any method to save a filter with the context_today instead of his value?
Thanks. Best regards.
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).
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
|Asked: 1/13/14, 12:27 PM|
|Seen: 5040 times|
|Last updated: 6/8/17, 5:04 AM|