2017-07-28 98 views
-1

任何人都可以告訴你怎麼計算時間這裏的區別時間就像IN,OUT,IN:-code什麼,我嘗試: -如何odoo計算時間之間的差異

@api.model 
@api.depends('attendance_manage_lines.punch_time') 
def _time_difference(self): 
    ls=[] 
    for item in self.attendance_manage_lines: 
     data = {} 
     data[item.punch_time]=str(item.punch_type) 
     ls.append(data)` 

現在如何計算: - enter image description here 此處In和OUT的區別在於工作時間和OUT和IN進入休息時間。

回答

0
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT 
from datetime import datetime, timedelta 


out = datetime.strptime(out, DEFAULT_SERVER_DATETIME_FORMAT) 
intime = datetime.strptime(intime, DEFAULT_SERVER_DATETIME_FORMAT) 
diff = out - intime 
#here out and in are punch intime and out times.output would be exact difference in datetime object 
+0

我的代碼中有什麼錯誤。 –

+0

你的代碼是什麼意思?我看不到計算結果。 –