32 lines
904 B
Python
32 lines
904 B
Python
# -*- coding: utf-8 -*-
|
|
import time
|
|
import hashlib
|
|
from odoo import models
|
|
|
|
|
|
class Common(models.Model):
|
|
_name = 'sf.sync.common'
|
|
_description = u'公用类'
|
|
|
|
def get_headers(self, token, secret_key):
|
|
'''
|
|
获取requests中的heardes参数
|
|
'''
|
|
timestamp = int(time.time())
|
|
check_str = '%s%s%s' % (token, timestamp, secret_key)
|
|
check_sf_str = hashlib.sha1(check_str.encode('utf-8')).hexdigest()
|
|
headers = {'TOKEN': token,
|
|
'TIMESTAMP': str(timestamp),
|
|
'checkstr': check_sf_str}
|
|
return headers
|
|
|
|
def get_add_time(self, parse_time):
|
|
"""
|
|
把时间增加8小时
|
|
:return:
|
|
"""
|
|
dt = datetime.datetime.strptime(parse_time, "%Y-%m-%d %H:%M:%S")
|
|
d = dt + datetime.timedelta(hours=8)
|
|
nTime = d.strftime("%Y-%m-%d %H:%M:%S")
|
|
return nTime
|