Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
I want to get Httprequest then get the client ip, but use below code in my module have a error. pls help, thanks very much
import openerp.addons.web.http as openerpweb @openerpweb.jsonrequest def get_ip_address(self, req): wsgienv = req.httprequest.environ env = dict( HTTP_HOST=wsgienv['HTTP_HOST'], REMOTE_ADDR=wsgienv['REMOTE_ADDR'], ) _logger.log("env:%d", env) return True
Get Error:AttributeError: 'list' object has no attribute 'httprequest'
It looks like you call jsonrequest once and httprequest another time. I was able to install this code:
Note: I modified the 2nd line.
import openerp.addons.web.http as openerpweb @openerpweb.httprequest def get_ip_address(self, req): wsgienv = req.httprequest.environ env = dict( HTTP_HOST=wsgienv['HTTP_HOST'], REMOTE_ADDR=wsgienv['REMOTE_ADDR'], ) #_logger.log("eng:%d",env) return True
I didn't import logger.
What URL are you calling to access your function?
sorry for asking question here. i am not able create object of http request in my own module.
<record id="lead_sample" model="ir.ui.view">
<field name="arch" type="xml">
<button type="action" name="download" string="Downloads" class="oe_button oe_highlight"/>
def download(self, cr, uid, req, token):
[('Content-Type', 'application/octet-stream; charset=binary'),
('Content-Disposition', content_disposition('filename.png', req))],
I have created this code but i don't know how to create http reqest object in my module
About This Community
This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 7/25/13, 11:04 PM|
|Seen: 5471 times|
|Last updated: 3/16/15, 8:10 AM|