dynamic selection for year [Closed]
The Question has been closedby
i have written functional field for date
def _get_year(self, cr, uid, context=None): year = int(time.strftime('%Y')) return [((year+r), (year+r)) for r in range(2)]
this is showing the values in selection field , if i try to save and edit the record,the value is not showing.
Value of selection fields are store as
char in database. So problem is that you are returning year as
int. You have to return value in char form.
return [(str((year+r)), str((year+r))) for r in range(2)]
This will solve your problem for sure.
year = 2000 #assign starting year year_range = int(time.strftime('%Y')[-2:]) #this will give current year (like 13 for 2013) [((str(year+r)), (str(year+r))) for r in range(year_range+1)]
If you want list from 2000 to 2013 + next 10 years, increment range value by 11 because loop starts from
[((str(year+r)), (str(year+r))) for r in range(year_range+11)]
About This Community
|Asked: 5/21/13, 5:58 AM|
|Seen: 1770 times|
|Last updated: 3/16/15, 8:10 AM|