Skip to Content
Menu
This question has been flagged
1 Reply
6269 Views


Odoo V12. In fields.date, is it possible to display month and year only?

ex. 01-2020


Avatar
Discard
Author Best Answer


# Outside the model

def get_years(): year_list = [] for i in range(2019, 2030): year_list.append((i, str(i))) return year_list


# Inside the model

month = fields.Selection([(1, 'January'), (2, 'February'), (3, 'March'), (4, 'April'),(5, 'May'), (6, 'June'), (7, 'July'), (8, 'August'),(9, 'September'), (10, 'October'), (11, 'November'), (12, 'December'), ], string='Month')

year = fields.Selection(get_years(), string='Year')

Avatar
Discard
Related Posts Replies Views Activity
1
Jan 24
16296
2
May 22
15146
2
Feb 22
27316
1
Jan 20
2544
1
Dec 19
4561