【发布时间】:2023-04-07 00:54:01
【问题描述】:
for emp in employee:
contract_id = contract_pool.search(cr, uid, [('employee_id','=',emp.employee_id.id)], context=context)
for contract in contract_pool.browse(cr, uid, contract_id, context=context):
for attendance in contract.working_hours.attendance_ids:
if day == attendance.dayofweek:
planned_time_in = attendance.hour_from
planned_time_out = attendance.hour_to
planned_wrkng_hrs = planned_time_out - planned_time_in
print planned_wrkng_hrs
actual_time_in = emp.time_in
actual_time_out = emp.time_out
actual_wrkd_hrs = actual_time_out - actual_time_in
print actual_wrkd_hrs
hrs_short = planned_wrkng_hrs - actual_wrkd_hrs
print hrs_short
这给了我如下输出:
9.00
8.57
0.43
我如何获得:
9:00
8:57
00:03
此处减去浮点值而不是时间。
【问题讨论】:
-
将时间转换为秒,然后进行运算,一旦得到秒的结果,除以 60 分钟,3600 小时
本站文章如无特殊说明,均为本站原创,如若转载,请注明出处:Odoo – 在python中减去2个“时间”字段 - Python技术站