Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
2 Vastaukset
4283 Näkymät

I want to get current day of the week and compare it with selection field value.Any idea?

Avatar
Hylkää
Paras vastaus

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.

Avatar
Hylkää
Paras vastaus

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.

0Monday
1Tuesday
2Wednesday
3Thursday
4Friday
5Saturday
6Sunday



Avatar
Hylkää
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
2
kesäk. 25
1335
0
toukok. 25
12
2
tammik. 25
2869
1
jouluk. 24
6560
1
marrask. 24
2956