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 date field in this format: "17/01/2013" and I'm trying to use the ORM search function to find all records that match a certain year say 2012 for instance.
I've tried something like this but it didnt work:
my_obj.search(cr, uid, [('date', '>=', '01/01/' + h1.year), ('date', '<=', '31/12/' + h1.year)], order='date')
but it didn't work.
How can I achieve this with the ORM search function? More general, how can I construct a query to search for all records matching a specified year using a date field in the format shown above?
Hi. If you do not have any exact error message, just the result is NULL, may be your date format isn't good. You can check the system date format by print. Ex.
for obj in my_obj.browse(cr,uid,[some_id]): print obj.date
You can see the result, and you can modify your search condition according the result. Any others, please give more info's.
This is a date format.:
date_planned = datetime.strptime(order.shipping_date, DEFAULT_SERVER_DATE_FORMAT)
please see that: for datetime: http://docs.python.org/2/library/datetime.html
and you can find a lot of relevant info's there: http://stackoverflow.com/questions/466345/converting-string-into-datetime
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/21/14, 9:43 PM|
|Seen: 3401 times|
|Last updated: 3/16/15, 8:10 AM|