Help

8

Relative Date (today, this month, e.g.) in Filter

How can I use a relative date like for example today for filtering?

I filtered all due / overdue invoices in the suppliers invoice list using the attribute "due date" "is less or equal than". As I want to create a template from this filter it should not refer to a concrete date like 22.05.2013 but to the relative date. So I could use the template every day without modification.

Avatar
Discard
5 Answers
8
Avatar
Borni DHIFI
Best Answer

Hi, To manage filters active mode developer *Activate the developer mode*. in displayed list choose Manage Filters and add your filter. in domain [['date_invoice','=',time.strftime('%Y-%m-%d')]] Thanks.

1 Comment
Avatar
Discard

@Borni DHIFI, i am sorry. I tried to add your post for developer info using Promote to Doc. but instead clicked wrongly on Convert as a comment. I am very sorry.

4
Avatar
Ray Carnes
Best Answer

In version 8, you can now do this:

  

In version 9, you can use this as a filter:

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

1 Comment
Avatar
Discard
Avatar
Sophie Kowalski
-

Is there a way to save the filter in that manner? I am looking for a way to save the relative filter for a report

1
Avatar
Philippe Thuaud
Best Answer

Hello,

I am trying to do this but I am confused on how to do this filter.

I am in Odoo v10 

In the accounting application.

in the list of invoices, I would like to add in the filter option an option to filter on the invoices from the last 7 days.

from the last month

from the last quarter

from the last year.


I don't understand how to do it.

I  go to developer mode, then in the manage filter and create a new one.

I am trying with this folowing info:

Filter name= Today

Model= Invoice

Action is left blank

Domain= [['date_invoice','=',time.strftime('%Y-%m-%d')]]

Context left as default []

Sort left by defualt []

Default filter is off

User is me

Active is enable


But then when I go to the list of invoice, I don't see the today option in the default filter option.

What I am doing wrong?

1 Comment
Avatar
Discard
Avatar
Marouane
-

Hi, I did the same thing and it worked for me, Thank's

0
Avatar
Mike Lorusso
Best Answer

HI, This is what I did

Cheers

Mike

\https://www.odoo.com/forum/help-1/question/odoo-11-ce-dynamic-dates-in-actions-162602

Avatar
Discard
0
Avatar
adas
Best Answer

hi i really need help to creat today filter on pos sales orders in odoo 11 no possibilities, always forced numeric date not Domain= [['date_invoice','=',time.strftime('%Y-%m-%d')]] but it show Domain= [['date_invoice','=',time.strftime('2019-01-21')]]

Avatar
Discard