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') ==> Januarydate.today().strftime('%b') ==> Januff 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>
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up| Related Posts | Replies | Views | Activity | |
|---|---|---|---|---|
|
1
Oct 25
|
12266 | |||
|
2
Jul 24
|
3831 | |||
|
1
Jun 24
|
6137 | |||
|
1
Oct 23
|
98 | |||
|
413 Request Entity Too Large
Solved
|
1
Aug 23
|
2194 |
1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.