Files
test/sf_base/commons/common.py

24 lines
605 B
Python

# -*- coding: utf-8 -*-
from odoo import models
import time
import hashlib
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