Help

8

Search within a period of date

Avatar
Mohamed arif

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

2 Comments
Avatar
Discard
Avatar
Francesco OpenCode
-

What version of OpenERP are you using?

Avatar
Mohamed arif
-

Version 7.

4 Answers
7
Avatar
Prakash
Best Answer

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

12 Comments
Avatar
Discard
Avatar
Ademola Oke
-

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/

Avatar
evon_dun
-

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.

Avatar
Prakash
-

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

Avatar
evon_dun
-

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

Avatar
Prakash
-

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

Avatar
evon_dun
-

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??

Avatar
Prakash
-

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

Avatar
evon_dun
-

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

Avatar
evon_dun
-

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

Avatar
Prakash
-

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.

Avatar
evon_dun
-

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

Avatar
Prakash
-

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

1
Best Answer

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

3 Comments
Avatar
Discard
Avatar
Mohamed arif
-

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.

Avatar
Francesco OpenCode
-

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.

Avatar
Mohamed arif
-

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.?

0
Avatar
Nikunj Antala
Best Answer

There is app available in app store Its a Paid app.



https://apps.odoo.com/apps/modules/10.0/odoo_advance_search/

Avatar
Discard
0
Avatar
Mohamed arif
Best Answer

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.?

1 Comment
Avatar
Discard
Avatar
Timothy Solomon
-

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.