Odoo Help


3 Answers

Andreas Brueckl Austria

--Andreas Brueckl--

| 8 8 9
Vienna, Austria
--Andreas Brueckl--
OpenERP Consulting and Development
Andreas Brueckl Austria
3/26/13, 8:01 AM

The model stock.move uses a timestamp value for field date. The following domain should return all moves where the date is earlier than today - 10 days:

[('date','<=', ((context_today()-datetime.timedelta(days=10)).strftime('%Y-%m-%d')))]

I assume, that you use the domain in a window action. If you want to use it in a view, you should use &lt;= instead of <=.

Wided Tunisia
3/26/13, 8:14 AM

Thank you very much, that worked.

Camptocamp SA Switzerland
4/23/13, 10:36 AM

+1 for this good answer As said Francesco, in a view you need to escape the % using %%

Gustavo Colombia
8/27/13, 12:24 PM

Hello, you used the context_today () like domain in the model and it works perfectly, but I try to do it with a datetime field and shows me an error message.

The code I use is

'agenda_id': fields.many2one ('delphos.citamedica.agenda', 'Agenda', required = True, domain = "[('doctor_id', '=', doctor_id), ('date', '> =', ((context_today ()). strftime ('% Y-% m-% d% H:% m:% S'))), ('date_deadline', '<=', ((context_today ()). strftime ('% Y-% m-% d% H:% m:% S')))] "),

The error message says: Uncaught Error: ValueError: No known conversion for% H

That could be my mistake?

Wided Tunisia
3/31/14, 6:37 AM

probably there should not be a space between "%" and "H"?

P.V.Anthony Singapore
4/23/16, 3:27 AM

Thank you very much for sharing this solution. It has helped me very much.

Aron Lorincz Hungary
6/16/16, 3:21 AM

How great it is that the documentation says almost nothing about this.


Francesco OpenCode Italy

--Francesco OpenCode--

| 7 8 11
Grottaglie, Italy
--Francesco OpenCode--

Italian Odoo Developer. Python lover. Beer addicted.

LINKEDIN: http://www.linkedin.com/in/francescoapruzzese

Francesco OpenCode Italy
3/26/13, 7:12 AM

Try this:

[('date', '&gt;=', (context_today() - datetime.timedelta(10)).strftime('%%Y-%%m-%%d') )]
Wided Tunisia
3/26/13, 7:39 AM

Unfortunately, that doesn't work.

Francesco OpenCode Italy
3/26/13, 7:57 AM

If you share the error we can help you. Why this code doesn't work?

Wided Tunisia
3/26/13, 8:18 AM

There's no error, it's a filter I'm creating in a view, when I use it I don't get my lines filtered. This is probably because filters in the views differ from the other filters. Anyway, thanks for your answer.

Camptocamp SA Switzerland
4/23/13, 10:36 AM

+1 for the format for views

Andres Brigard Colombia
8/20/19, 4:26 PM

It worked fine with just one %.

[('date', '&gt;=', (context_today() - datetime.timedelta(10)).strftime('%Y-%m-%d') )]

Wided Tunisia
3/26/13, 8:03 AM

The only expression that works is:

[('move_ids.date', '=' , (time.strftime('%Y-%m-%d'))]

I don't know how to integrate delay in it.

Mihai Marius Romania
10/21/13, 7:47 PM

Thanks for the update. it works :). For your question you can find in search view for crm.lead examples for delays. Hope this is not too late. Cheers!

Wided Tunisia
3/31/14, 6:45 AM

Thanks, but I didn't find the example you've mentioned in the crm.lead search view. Can you give the line number, please?

Mihai Marius Romania
3/31/14, 7:09 AM

Hi, In view "crm.lead.report.select" first 3 or 4 lines are filter buttons which are using domain filters in views for current year, month or last month.

Ask a Question
Keep Informed
4 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.

Odoo Training Center

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

Test it now