Odoo Help

Welcome!

This community 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.

2

Creating "This week" or "Today +7 days" filter - not working

By
Zohair Iyaz
on 12/28/15, 12:49 AM 905 views


Model: Project.task
Custom Field: x_Planned_Start_Date (type:date)


Custom Filter #1:


[

 

 ['x_Task_Status', '=', 'Open'],
 [('x_Planned_Start_Date','<=', ((context_today()+datetime.timedelta(days=7)).strftime('%Y-%m-%d')))]
]


Error for Custom Filter # 1:

File
"/opt/bitnami/apps/odoo/lib/odoo-8.0.post20151126-py2.7.egg/openerp/osv/expression.py",
line 308, in distribute_not
    elif token in DOMAIN_OPERATORS_NEGATION:
TypeError: unhashable type: 'list'

Source: https://www.odoo.com/fr_FR/forum/help-1/question/filter-by-date-of-today-with-a-delay-8149



Custom Filter #2:

[

	['x_Task_Status', '=', 'Open'],
	['x_Planned_Start_Date', '<=', time.strftime('%Y-%m-%d %H:%M:%S',time.gmtime(time.time()+7243600))]
]

 

Custom Filter #2:

Uncaught Error: Failed to evaluate search criterions: 
{"code":400,"message":"Evaluation Error","data":{"type":"local_exception","debug":"Local evaluation failure\nAttributeError: object has no attribute 'gmtime'\n\n{\"domains\":[[],\"[\\n\\n\\t['x_Task_Status', '=', 'Open'],\\n\\t['x_Planned_Start_Date', '<=', time.strftime('%Y-%m-%d %H:%M:%S',time.gmtime(time.time()+7243600))]\\n]\"],\"contexts\":[{\"lang\":\"en_US\",\"tz\":\"Asia/Karachi\",\"uid\":1,\"params\":{\"action\":192,\"page\":0,\"limit\":80,\"view_type\":\"list\",\"model\":\"project.task\",\"_push_me\":false}},\"{}\"],\"group_by_seq\":[\"{}\"]}"}}


Source: https://www.odoo.com/fr_FR/forum/help-1/question/server-action-to-set-deadline-in-7-days-30277
2
Zohair Iyaz
On 1/8/16, 2:01 AM

[ '|', [ 'x_Planned_Start_Date', '=', (context_today()+relativedelta(days>1)).strftime('%Y-%m-%d'), ], [ 'x_Planned_Start_Date', '=', (context_today()+relativedelta(days<7)).strftime('%Y-%m-%d'), ] ]


Above works (tasks with Planned Start Date day after tomorrow and less than next week. User Requirement)

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

Asked: 12/28/15, 12:49 AM
Seen: 905 times
Last updated: 9/14/16, 12:03 AM