跳至內容
選單
此問題已被標幟
2 回覆
4561 瀏覽次數

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
8月 25
1893
1
7月 25
2522
2
7月 25
7972
2
7月 25
4408
2
7月 25
4128