I want to make a year selection where the default year is now.
This is my .py
def get_years():
year_list = []
for i in range(2022, 2036):
year_list.append((i, str(i)))
return year_list
def get_year(self):
return str(datetime.now().year)
year = fields.Selection(get_years(), string='Year', default=get_year)
and this is my .xml
<field name="year">
But I get this error
ValueError: Wrong value for wizard.report.purchase.tracking.year: '2023'
What should I do?
Thank you for your help
You have to set the string type key and pair value of touple for the selection field.
also You can set default value directly at selection.