From 6901c4f981ca1562ac5ce85a3c6c08faad7ffe88 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Fri, 7 Jun 2013 11:30:44 +0200 Subject: [FIX] export: allow excluding special virtual fields from exportable data For example the virtual "Access Rights" fields on res.users cannot be browsed and cannot currently by exported. bzr revid: odo@openerp.com-20130607093044-y3bct44ralu8yf0o --- addons/web/controllers/main.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'addons/web/controllers') diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index 93e08db64ea..d0bdfe3cdc4 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -1481,6 +1481,8 @@ class Export(openerpweb.Controller): if all(dict(attrs).get('readonly', True) for attrs in field.get('states', {}).values()): continue + if not field.get('exportable', True): + continue id = prefix + (prefix and '/'or '') + field_name name = parent_name + (parent_name and '/' or '') + field['string'] -- cgit v1.2.3 From 36e113e6bd215e56e8bea2157db4f90b838cb750 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Tue, 11 Jun 2013 13:03:27 +0200 Subject: [FIX] web: handle monodb correctly when server started with "--no-database-list" option bzr revid: chs@openerp.com-20130611110327-sipc2er6z1ch7leb --- addons/web/controllers/main.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'addons/web/controllers') diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index d0bdfe3cdc4..66db8aa6974 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -84,9 +84,9 @@ def rjsmin(script): ).strip() return result -def db_list(req): +def db_list(req, force=False): proxy = req.session.proxy("db") - dbs = proxy.list() + dbs = proxy.list(force) h = req.httprequest.environ['HTTP_HOST'].split(':')[0] d = h.split('.')[0] r = openerp.tools.config['dbfilter'].replace('%h', h).replace('%d', d) @@ -103,7 +103,7 @@ def db_monodb_redirect(req): return (db_url, False) try: - dbs = db_list(req) + dbs = db_list(req, True) except xmlrpclib.Fault: # ignore access denied dbs = [] @@ -757,6 +757,10 @@ class Database(openerpweb.Controller): @openerpweb.jsonrequest def get_list(self, req): + # TODO change js to avoid calling this method if in monodb mode + monodb = db_monodb(req) + if monodb: + return [monodb] return db_list(req) @openerpweb.jsonrequest -- cgit v1.2.3 From ce68573126efe2386b9c4c1c2013c89b6d037a15 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Tue, 11 Jun 2013 16:50:28 +0200 Subject: [FIX] web: handle monodb correctly when server started with "--no-database-list" option bzr revid: chs@openerp.com-20130611145028-f98x6inytlr3ijjg --- addons/web/controllers/main.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'addons/web/controllers') diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index 66db8aa6974..400f5507c04 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -32,6 +32,7 @@ except ImportError: import openerp import openerp.modules.registry from openerp.tools.translate import _ +from openerp.tools import config from .. import http openerpweb = http @@ -102,25 +103,21 @@ def db_monodb_redirect(req): if db_url: return (db_url, False) - try: - dbs = db_list(req, True) - except xmlrpclib.Fault: - # ignore access denied - dbs = [] + dbs = db_list(req, True) # 2 use the database from the cookie if it's listable and still listed cookie_db = req.httprequest.cookies.get('last_used_database') if cookie_db in dbs: db = cookie_db - # 3 use the first db - if dbs and not db: + # 3 use the first db if user can list databases + if dbs and not db and (config['list_db'] or len(dbs) == 1): db = dbs[0] # redirect to the chosen db if multiple are available if db and len(dbs) > 1: query = dict(urlparse.parse_qsl(req.httprequest.query_string, keep_blank_values=True)) - query.update({ 'db': db }) + query.update({'db': db}) redirect = req.httprequest.path + '?' + urllib.urlencode(query) return (db, redirect) @@ -758,10 +755,13 @@ class Database(openerpweb.Controller): @openerpweb.jsonrequest def get_list(self, req): # TODO change js to avoid calling this method if in monodb mode - monodb = db_monodb(req) - if monodb: - return [monodb] - return db_list(req) + try: + return db_list(req) + except xmlrpclib.Fault: + monodb = db_monodb(req) + if monodb: + return [monodb] + raise @openerpweb.jsonrequest def create(self, req, fields): -- cgit v1.2.3 From 22a8e5266e289af50df2aaa51b73c59e3aea97b4 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Tue, 11 Jun 2013 18:35:27 +0200 Subject: [FIX] web: calls to openerp methods do not raises xmlrpc Fault anymore bzr revid: chs@openerp.com-20130611163527-k6yzb604c36n2wha --- addons/web/controllers/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/controllers') diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index 0ab65b43379..5ea54abb549 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -768,7 +768,7 @@ class Database(openerpweb.Controller): # TODO change js to avoid calling this method if in monodb mode try: return db_list(req) - except xmlrpclib.Fault: + except openerp.exceptions.AccessDenied: monodb = db_monodb(req) if monodb: return [monodb] -- cgit v1.2.3