def onchange_time(self):
    for rec in self:
        time1 = datetime.strptime(rec.time1, '%Y-%m-%d %H:%M:%S')
time2 = datetime.strptime(rec.time2, '%Y-%m-%d %H:%M:%S')
rec.result = (time2 - time1).seconds / float(60 * 60)
Convert char to datetime odoo 9