0
我想用戶的公網IP地址來控制的OpenERP的sign_in,對於我試圖通過existant IP如何獲得openerp用戶的公共ip地址?
代碼給IP用戶比較下面顯示的公網IP:
my_ip = urlopen('http://ip.42.pl/raw').read()
我在hr_attendance,通過添加一些行
def _altern_si_so(self, cr, uid, ids, context=None):
if my_ip=='aa.aa.aa.aa': # Want to compare IP user by 'aa.aa.aa.aa'
return False
return True
msg = 'Error ! Sign in (resp. Sign out) must follow Sign out (resp. Sign in)'
my_ip = urlopen('http://ip.42.pl/raw').read()# get public ip address
_constraints = [(_altern_si_so, my_ip, ['action'])]
我認爲你的代碼對於odoo 8是正確的 –