Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
10092 Zobrazení

When I configure a filter with a relative date in odoo studio, when saving it the date becomes static.

do you know how i can do this?

filter origin: [["invoice_date","=",datetime.datetime.now()]]

Filter after save: [["invoice_date","=","2022-04-07T21:12:05.906Z"]]


Thanks!!!

Avatar
Zrušit

<filter string="Today" name="today" domain="[('create_date', '&gt;', (context_today() - datetime.timedelta(days=1)).strftime('%%Y-%%m-%%d'))]"/>

Autor Nejlepší odpověď

Thanks Niyas, this is the solution: 

Use case : In the CRM app, I want to be able to filter on the task changed this week/last24H/no change in the past 30 days.


How to :


1. Create a new filter with the date you want to filter in Odoo with studio (search view). Any filter would work, we just need Studio to create a view. 


2. Open the studio view that was created (Odoo Studio: MODEL.search.inherit.VIEW customization) 


3. Change the domain :


CHANGED THIS WEEK : 

domain="[('date','<',time.strftime('%%Y-%%m-%%d 23:59:59')),('date','>=',(datetime.date.today()-datetime.timedelta(days=7)).strftime('%%Y-%%m-%%d 00:00:00'))]"


CHANGED THIS DAY  : 

domain="[('date','<',time.strftime('%%Y-%%m-%%d 23:59:59')),('date','>=',(datetime.date.today()-datetime.timedelta(hours=24)).strftime('%%Y-%%m-%%d 00:00:00'))]"


NO CHANGE LAST 30 DAYS

domain="[('date','<',(datetime.date.today()-datetime.timedelta(days=30)).strftime('%%Y-%%m-%%d 00:00:00'))]"


'date' = update this field and use the name of field you need to filter.


********

Example : 

domain="[('date_last_stage_update','<',time.strftime('%%Y-%%m-%%d 23:59:59')),('date_last_stage_update','>=',(datetime.date.today()-datetime.timedelta(days=7)).strftime('%%Y-%%m-%%d 00:00:00'))]"/>

domain="[('date_last_stage_update','<',time.strftime('%%Y-%%m-%%d 23:59:59')),('date_last_stage_update','>=',(datetime.date.today()-datetime.timedelta(hours=24)).strftime('%%Y-%%m-%%d 00:00:00'))]"/>

domain="[('date_last_stage_update','<',(datetime.date.today()-datetime.timedelta(days=30)).strftime('%%Y-%%m-%%d 00:00:00'))]"/>

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
2
bře 25
6913
3
kvě 23
4753
1
čvn 24
1475
1
led 19
6263
1
říj 18
4307