I want to get current day of the week and compare it with selection field value.Any idea?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Księgowość
- Zapasy
- PoS
- Project
- MRP
To pytanie dostało ostrzeżenie
To get current day :
current_day = datetime.today().strftime('%A') # 'Wednesday'
and for comparing the selection field see my below code.
for cal in attendance.employee_id.resource_calendar_id.attendance_ids.filtered(lambda line: dict(line._fields['dayofweek'].selection).get(line.dayofweek) == current_day and line.day_period == 'morning'):
Here,
'line' is the object like self
'dayofweek' is the selection field.
like this you can compare your selection field key with other variable.
You can use weekday() of datetime.date class function.
The weekday() of datetime.date class function is used to return the integer value corresponding to the specified day of the week.
0 | Monday |
1 | Tuesday |
2 | Wednesday |
3 | Thursday |
4 | Friday |
5 | Saturday |
6 | Sunday |
Podoba Ci się ta dyskusja? Dołącz do niej!
Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!
Zarejestruj sięPowiązane posty | Odpowiedzi | Widoki | Czynność | |
---|---|---|---|---|
|
2
lip 25
|
3324 | ||
|
2
lip 25
|
3043 | ||
|
2
cze 25
|
1813 | ||
|
0
maj 25
|
14 | ||
Odoo wrong company logo in email
Rozwiązane
|
|
2
sty 25
|
3378 |