콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
4525 화면

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

아바타
취소
베스트 답변

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.

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



아바타
취소
관련 게시물 답글 화면 활동
1
7월 25
2469
2
7월 25
7920
2
7월 25
4338
2
7월 25
4075
2
6월 25
2668