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.

8

Search within a period of date

By
arif
on 4/30/13, 5:22 AM 10,380 views

How I can add option to search any record by period for a date/datetime field? User should able to select to date ranges to find records.

In previous versions we have to add date field in search view only, so that the user can select date and datetime ranges and easily find records.

Using Save Custom Filter, we can save filter for static or related date ranges only. I want to enter date ranges as user needs.

Have any suggestions please

What version of OpenERP are you using?

Francesco OpenCode
on 4/30/13, 11:27 AM

Version 7.

arif
on 4/30/13, 11:29 AM
5

Prakash

--Prakash--
3173
| 5 4 7
Bikaner, India
--Prakash--

OpenERP Devloper at SunARC Technology

Prakash
On 7/26/13, 10:31 AM

Search Date Range solved in openerp 7 using the below link:-

http://forum.openerp.com/forum/topic31468.html

In python, in "columns", add two dummy functional fields like this:

'due_date_from':fields.function(lambda *a,**k:{}, method=True, type='date',string="Due date from"),
'due_date_to':fields.function(lambda *a,**k:{}, method=True, type='date',string="Due date to"),

And in the search view:
<field name="due_date_from" filter_domain="[('date_due','&gt;=',self)]"/>
<field name="due_date_to" filter_domain="[('date_due','&lt;=',self)]"/>

The above code working in the [Normal Form] search view and also reports using SQL query

Nice workaround! Works very well. Also possible using the AND mode in advanced search. See http://help.openerp.com/question/1130/how-to-use-and-or-operators-in-advanced-filters/

Bam Technologies Limited, Ademola Oke
on 8/6/13, 11:59 AM

I did same in my OpenErp v6.1 but can't understand how to use value of these in the reports... please help if anyone knows about it.

evon_dun
on 8/19/13, 2:39 AM

The above same code also working in the report search date range.

Prakash
on 8/19/13, 2:59 AM

Sorry I didn't get you. I tried adding these in the report but it returns [], since lamda can never return.

evon_dun
on 8/19/13, 3:55 AM

In search box when typing date have you get auto suggestion From Date and To Date in the search box after adding the code?....

Prakash
on 8/19/13, 4:40 AM

No, i don't. My searching is perfect but i just want to add this range on top of my invoice report like it does in other partner reports. From 'Date' to 'Date'. Got it??

evon_dun
on 8/19/13, 4:57 AM

The above code working in the reports search view using Sql query. Are u using same?..

Prakash
on 8/19/13, 5:22 AM

No, i just added these two fields in my report like we add other fields in openoffice, please guide how to use sql query for the same..

evon_dun
on 8/19/13, 5:24 AM

No, i just added these two fields in my report like we add other fields in openoffice, please guide how to use sql query for the same..

evon_dun
on 8/20/13, 3:52 AM

using openoffice i not used date range or sql query. Date range and sql used in report For example Report --> Sales --> Sales Analysis. Actually data range working based on given input from the user.

Prakash
on 8/20/13, 4:04 AM

Then what do you suggest me to get the range in my reports too any idea?

evon_dun
on 8/20/13, 4:12 AM

I think in openoffice report there is no options wizard or select input to the user. so i suggest in openoffice report search view add date range and filter data and select print options to view report

Prakash
on 8/20/13, 4:22 AM
1

Francesco OpenCode

--Francesco OpenCode--
3608
| 5 7 9
Grottaglie, Italy
--Francesco OpenCode--

Italian Odoo (OpenERP) Modules Developer LINKEDIN: http://www.linkedin.com/in/francescoapruzzese

Francesco OpenCode
On 4/30/13, 11:49 AM

If you wanna search a date reange you must use the advanced filter.

  1. Open the filters popup and expand Andvanced Filters voice.
  2. Select your date (or datetime) field and select the greater or equal then parameter and insert the smallest data (smallest limit).
  3. Then apply the filter

image description

Use the some passes to insert another filter with the biggest limit but this time select less or equal then parameter. Apply this filter, too.

image description

Now you have your range limit with date values

image description

Thanks Francesco Apruzzese,

But this always will search with saved date only. If user wants search with another period, he have to select field, condition and date again twice. It is not user friendly.

arif
on 4/30/13, 11:54 AM

This is the only way. If you insert the date field in filters, you can only search the precis date (only one day) for time. I know this is not user friendly but this is the way.

Francesco OpenCode
on 4/30/13, 11:56 AM

In the List view of Journal Items ( Accounting / Journal Entries / Journal Items ) , here we can see Filter option by 'Period' and 'Journal' in old version style. I checked and it is working fien. Can someone explain how these fields are added.?

arif
on 5/12/13, 9:35 AM
0
arif
On 5/12/13, 9:38 AM

In the List view of Journal Items ( Accounting / Journal Entries / Journal Items ) , here we can see Filter option by 'Period' and 'Journal' in old version style. I checked and it is working fine.

image description

Can someone explain how these fields are added.?

Periods are actually normal openERP objects, not dates. So the name of the period is "05/2013" in that case, so its not actually searching by date, its just searching by many2one type link. Prakash's solution is the best workaround in my opinion.

Timothy Solomon
on 9/5/13, 5:45 AM

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

0 follower(s)

Stats

Asked: 4/30/13, 5:22 AM
Seen: 10380 times
Last updated: 2/8/16, 1:17 AM