Hi,
I need to display current status of timesheet,for that I need current month,can you please help me to find current month from current date??
Thanks in advance.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hi,
I need to display current status of timesheet,for that I need current month,can you please help me to find current month from current date??
Thanks in advance.
i assume you have date field in timesheet.
to get moth from that date field use below code
from datetime import datetime
timesheet_date = datetime.strptime(self.timesheet_date, DEFAULT_SERVER_DATE_FORMAT)
month = timesheet_date.month
you can do this in one line timesheet_date = datetime.strptime(self.timesheet_date, DEFAULT_SERVER_DATE_FORMAT).month The return type of month is integer.
==If you want to get the number of the current month then try,
date.today().month
If you want to get the name of the current month then try,
date.today().strftime('%B')
If you want to get the name of the current month in short then try,
date.today().strftime('%b')
For Example, If todays date is 05-01-2019 then
date.today().month ==> 1
date.today().strftime('%B') ==> January
date.today().strftime('%b') ==> Jan
uff si funciona con .year .day
year = date.today().year
mes = date.today().month
dia = date.today().day
gracias!!!
you can filter using domain<field name="domain">[('date_field', 'ilike' , context_today().strftime('%m-%Y'))]</field>