Skip to content

Instantly share code, notes, and snippets.

@sehrishnaz
Created July 29, 2021 06:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sehrishnaz/63f0914912c729ad47990b6db7a5764d to your computer and use it in GitHub Desktop.
Save sehrishnaz/63f0914912c729ad47990b6db7a5764d to your computer and use it in GitHub Desktop.
How to use and manipulate Date field in Odoo
from datetime import datetime, timedelta, date
class some_model(models.Model):
_name = 'some.model'
# creating date field in odoo class
date_start = fields.Date(string="Start Date")
@api.one
def button_click(self):
# converting string date value into python date object
date_start = datetime.strptime(self.date_start, '%Y-%m-%d').date()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment