Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
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
This platform 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.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 5/21/13, 5:58 AM|
|Seen: 2437 times|
|Last updated: 3/16/15, 8:10 AM|