Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
4 ตอบกลับ
11002 มุมมอง


I tried to calculate attendance hours from check in/out,  ... Code work fin in local computer but when install addons on the server. Issue showed up

This is error msg:

Date_check_out =employee.datetime + timedelte(hours=3) 

Unsupported operation type +: 'bool' and datetime.timedelta(hours=3)

Note: attendance list have mane lines of check in /out records

when calculate attendance of employee with no attendance "zero attendance hours" no error happen,    only when attendance have values

odoo12 CE. 

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi,

Regarding this error that you are getting "Unsupported operation type +: 'bool' and datetime.timedelta(hours=3)" , might be due to as there is no value inside the field employee.datetime, as there is no value in the field it will return False, that is why you are getting the above error. Add a if condition and make sure that the field contains value.

Thanks

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

I solve it by adding if condition. If. It empty will add now date

Thank u all

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

How can I find the difference between the dates in the two fields?

อวตาร
ละทิ้ง

please use English

คำตอบที่ดีที่สุด

You are trying to add with a bool function and there is a typo error in your code. Instead of function timedelta  you used timedelte. 

try to change like this,

if employee.datetime:
assert isinstance(employee.datetime, datetime), 'Datetime instance expected'
Date_check_out = employee.datetime + timedelta(hours=3)
อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
2
มิ.ย. 25
875
2
มี.ค. 16
16716
5
ต.ค. 23
10026
2
มิ.ย. 25
6927
0
ต.ค. 23
1230