Skip to Content
Menu
This question has been flagged
22 Replies
48664 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

Avatar
Discard

What version of OpenERP are you using?

Author

Version 7.

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

Avatar
Discard

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/

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.

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

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

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

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

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

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

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

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.

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

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

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

Avatar
Discard
Author

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.

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.

Author

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

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

Avatar
Discard

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.

Related Posts Replies Views Activity
2
Mar 15
3838
1
Mar 15
9320
2
Jan 23
13045
1
Dec 20
20513
0
Mar 15
3392