Hi there,
ist there an easy way to set a date field to the first of January of the current year ?
As i know i can set a date field to the current date:
Kind regards,
Franz
date_to = fields.Date(string="End Date", default=fields.Date.today)
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hi there,
ist there an easy way to set a date field to the first of January of the current year ?
As i know i can set a date field to the current date:
Kind regards,
Franz
date_to = fields.Date(string="End Date", default=fields.Date.today)
Hello
import time
date_to = fields.Date(string="End Date", default=time.strftime('%Y-01-01'))
Hi David,
Your solution, save my time.
Thank You +1
Hello Franz,
Get current year and append to field's default value
current_year = datetime.now().year date_field = fields.Date("Date Field",default=datetime.strptime('%s-01-01' % (current_year),'%Y-%m-%d'))
Thanks,
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up
Hello David,
it works like a charm, thank you so much !
The other solution is also interesting for me !
Franz