i was create new module on OpenERP 7 and this module must save user IP Address, how can i get the user IP Address not server IP Address?
below my code and it give error "NameError: global name 'os' is not defined"
_columns = { 'ip_address': fields.function(_calculate_ipaddress,type='char',string='IP Address',store=True), }
def _calculate_ipaddress(self,cr,uid,ids,fields,args,context={}):
res = {}
for at in self.browse(cr,uid,ids,context=context):
res[at.id] = os.environ["REMOTE_ADDR"]
return res
You can get the user his IP address in python with os.environ["REMOTE_ADDR"] so I assume you should trigger a function and then store the address somewhere.
thanks for reply.. i get this error: NameError: global name 'os' is not defined i wont to save it on function field _columns = { 'ip_address': fields.function(_calculate_ipaddress,type='char',string='IP Address',store=True), } def _calculate_ipaddress(self,cr,uid,ids,fields,args,context={}): res = {} for at in self.browse(cr,uid,ids,context=context): res[at.id] = os.environ["REMOTE_ADDR"] return res
hope this will helps: https://learnopenerp.blogspot.com/2020/07/get-web-httprequest-in-odoo.html