Skip to content

Instantly share code, notes, and snippets.

@tienhieuD
Last active July 18, 2017 03:25
Show Gist options
  • Save tienhieuD/dd89646da0f8c5a38ae51b7568a43f44 to your computer and use it in GitHub Desktop.
Save tienhieuD/dd89646da0f8c5a38ae51b7568a43f44 to your computer and use it in GitHub Desktop.
@api.model
def _get_list_namhoc(self):
lst_namhoc=[]
for year in range(1990,2050):
item = str(year) + "-" + str(year+1)
lst_namhoc.append( (item, item) )
return lst_namhoc
@api.model
def _get_namhoc_now(self):
now = datetime.datetime.now()
year = now.year
if now.month <= 9:
year -= 1
return str(year) + "-" + str(year+1)
namhoc = fields.Selection(
string="Năm học",
selection= _get_list_namhoc,
default = _get_namhoc_now,
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment