I need to get current url from browser and extract the name of the opened model. I have 3 models: audit, dysfunction and action, action has a selection field containing 2 choices: audit or dysfunction. So when I create an action, I can choose by myself, but when I create an audit, then in the audit form create an action, I want the selection field to take 'audit' as type from the first. I noticed that when we enter the action form from the audit form the URL still holds the name of the first model which is 'audit'. Audit model has a many2many relation with action model. I wrote this line in the init function:
print (self.env._current_browser()._current_page)
but it gives me this error:
AttributeError: 'Environment' object has no attribute '_current_browser'
I alse tried this code:
import os.path
from urlparse import urlparse,parse_qs
print 'hello update'
url = os.environ["REQUEST_URI"]
parsed = urlparse.urlparse(url)
print urlparse.parse_qs(parsed.query)['model']
It gives me this error:
KeyError: 'REQUEST_URI'
I also tried this code:
from openerp import http
print http.request.httprequest.full_path
It gives me this:
/web/dataset/call_kw/action/create?
But I want it to return this url:
http://localhost:8069/web?#id=10&view_type=form&model=audit&menu_id=201&action=221
I'm working with python 2.7, odoo 8, windows 7.
Please Help. Thanks.