In Odoo version 8 Select database / Manage Databases view using the below URL:-
http://localhost:8069/web/database/selector
Note: Default Port No 8069. change Url based on your port no configuration.
EDIT:
GitHub Source Code https://github.com/prakashsukraj/Odoo-DBRestrict
I just finished a new module "web_dbrestrict" that Database Manager page restrict redirect to password page.
__openerp__.py
{
'name': 'Web DB Restrict',
'category': 'Hidden',
'version': '1.0',
'description': """
OpenERP Web core module.
========================
This module provides Database Manager page restrict redirect to password page.
""",
'depends': ['web'],
'data': [
'views/web_dbrestrict.xml',
],
'installable': True,
'application': True,
}
views/web_dbrestrict.xml
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="dbmanager_password" name="DB Password">
<t t-call="web.login_layout">
<form class="oe_login_form" role="form" action="/web/dbmanager_password" method="post">
<div class="form-group field-password">
<label for="password" class="control-label">Password</label>
<input type="password" name="password" id="password" class="form-control" required="required" t-att-autofocus="'autofocus' if login else None"/>
</div>
<p class="alert alert-danger" t-if="error">
<t t-esc="error"/>
</p>
<p class="alert alert-success" t-if="message">
<t t-esc="message"/>
</p>
<div class="clearfix oe_login_buttons">
<button type="submit" class="btn btn-primary">Log in</button>
</div>
</form>
</t>
</template>
</data>
</openerp>
web_dbrestrict/controllers/main.py
import jinja2
import os
import simplejson
import sys
import openerp
import openerp.modules.registry
from openerp.tools import topological_sort
from openerp import http
from openerp.http import request, serialize_exception as _serialize_exception
if hasattr(sys, 'frozen'):
# When running on compiled windows binary, we don't have access to package loader.
path = os.path.realpath(os.path.join(os.path.dirname(__file__), '..', 'views'))
loader = jinja2.FileSystemLoader(path)
else:
loader = jinja2.PackageLoader('openerp.addons.web', "views")
env = jinja2.Environment(loader=loader, autoescape=True)
env.filters["json"] = simplejson.dumps
db_monodb = http.db_monodb
def module_installed_bypass_session(dbname):
loadable = http.addons_manifest.keys()
modules = {}
try:
registry = openerp.modules.registry.RegistryManager.get(dbname)
with registry.cursor() as cr:
m = registry.get('ir.module.module')
# TODO The following code should move to ir.module.module.list_installed_modules()
domain = [('state','=','installed'), ('name','in', loadable)]
ids = m.search(cr, 1, [('state','=','installed'), ('name','in', loadable)])
for module in m.read(cr, 1, ids, ['name', 'dependencies_id']):
modules[module['name']] = []
deps = module.get('dependencies_id')
if deps:
deps_read = registry.get('ir.module.module.dependency').read(cr, 1, deps, ['name'])
dependencies = [i['name'] for i in deps_read]
modules[module['name']] = dependencies
except Exception,e:
pass
sorted_modules = topological_sort(modules)
return sorted_modules
def module_boot(db=None):
server_wide_modules = openerp.conf.server_wide_modules or ['web']
serverside = []
dbside = []
for i in server_wide_modules:
if i in http.addons_manifest:
serverside.append(i)
monodb = db or db_monodb()
if monodb:
dbside = module_installed_bypass_session(monodb)
dbside = [i for i in dbside if i not in serverside]
addons = serverside + dbside
return addons
# In the above code Import and method copy and paste from the web/main.py file
class Database_Password(openerp.addons.web.controllers.main.Database):
@http.route('/web/database/manager', type='http', auth="none")
def manager(self, **kw):
request.session.logout()
return http.local_redirect('/web/password')
@http.route('/web/password', type='http', auth='public', website=True)
def pasword(self, redirect=None, **post):
return request.render('web_dbrestrict.dbmanager_password', {'url_root': request.httprequest.url_root})
@http.route('/web/dbmanager_password', type='http', auth='public', website=True)
def dbmanager_password(self, cert_type=None, **post):
password = request.params['password']
if password == 'Your_Password': #user enter password matched redirect to DBManager page
return env.get_template("database_manager.html").render({
'modules': simplejson.dumps(module_boot()),
})
else:
values = request.params.copy()
values['error'] = "Wrong password"
return request.render('web_dbrestrict.dbmanager_password', values)
web_dbrestrict/views
copy and paste the "database_manager.html" File from the location web/views to web_dbrestrict/views
i'm also looking to restrict this in the same manner as you would with .htaccess in Apache (eg. restrict access to a certain fixed IP). I'll post back here if I find a solution.
Hi Luke, happy to hear that ! Looking forward to your feedback.
Why don't you script inside the webpage? Check which user is logged in with which preferences.. if the scenario you want matches you show the button that redirects to the /web/database/manager page. If this doesn't match you don't show the button.
@phoebe: I updated my custom module code to restrict DBManager page redirect to password page.
Is there any solution now?
Thomas the solution is given in the post below here. This is pretty much your prototype.
updated GitHub Source Code https://github.com/prakashsukraj/Odoo-DBRestrict