コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
4418 ビュー

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



アバター
破棄
関連投稿 返信 ビュー 活動
2
7月 25
2966
2
6月 25
1788
0
5月 25
14
2
1月 25
3345
1
12月 24
6916