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.

3

Is it possible to show the 'year' in date field as drop down like selection or many2one in openerp? [Closed]

By
Jasad
on 9/25/13, 10:49 AM 3,832 views

The Question has been closed

by
Ray Carnes
on 09/26/2013 14:34:47

Is it possible to show the 'year' in date field as drop down like selection or many2one in openerp? . I have a situation that, i need to choose the year only from date field as a drop down.

i have the problem same with u, and i use your code 'tahun': fields.selection([(num, str(num)) for num in range(1900, (datetime.now().year)+1 )], 'Year'), error undefined datetime and now and i have use code import datetime...but its doesnt work..

Susi
on 4/29/16, 5:58 AM
5
Jasad
On 9/26/13, 7:24 AM

Hi All,

Finally found out the answer:

eg: 'year': fields.selection([(num, str(num)) for num in range(1900, (datetime.now().year)+1 )], 'Year'),

thank you, +1

Bejaoui Souheil
on 3/18/15, 4:59 AM

great!!

MEXYTUL, Diego Calzadilla
on 3/26/15, 1:41 PM

Thanks for this good answer! For Odoo 8: year = fields.Selection([(num, str(num)) for num in range( ((datetime.datetime.now().year)-10), ((datetime.datetime.now().year)+1) )] to get the last 10 years as a selection.

tertiadev
on 5/9/16, 4:30 AM

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 9/25/13, 10:49 AM
Seen: 3832 times
Last updated: 5/9/16, 4:11 AM